Question: Error in procedure

Hello,

I'm having an issue with this and I can't seem to fix it. Any help is greatly appreciated! Thank you in advance!!! For some reason mapleprimes won't let me upload the worksheet so I have pasted it below this message.

 

Kind regards.

Gambia Man

with(LinearAlgebra); UseHardwareFloats; with(plots); interface(rtablesize = infinity); with(Statistics);
L := 4; U := 1;
V := proc (x, y) options operator, arrow; piecewise((1/4)*L <= x and x <= (1/2)*L and (1/4)*L <= y and y <= (1/2)*L, U) end proc;
plot3d(V(x, y), x = 0 .. L, y = 0 .. L);

Vij := proc (ni, mi, nj, mj) local Xi, Xj; option remember; global U, L; Xi := 2*sin(ni*evalf(Pi)*x/L)*sin(mi*evalf(Pi)*y/L)/L; Xj := 2*sin(nj*evalf(Pi)*x/L)*sin(mj*evalf(Pi)*y/L)/L; return U*(int(int(Xi*Xj, x = (1/4)*L .. (1/2)*L), y = (1/4)*L .. (1/2)*L)) end proc;
HamilMat := proc (K::integer) local ni, mi, nj, mj, N, Hamil, Eigenvec, i, j, res; option remember; global Vij, U, L; N := K^2; ni := Vector(N); mi := Vector(N); nj := Vector[row](N); mj := Vector[row](N); for i to N do for j to K do res := (i+K-j)/K; if type(res, integer) = true then ni[i] := j; nj[i] := j; mi[i] := res; mj[i] := res end if end do end do; Hamil := Matrix(N, shape = symmetric); for i to N do for j from i to N do if i <> j then Hamil(i, j) := Vij(ni[i], mi[i], nj[j], mj[j]) elif i = j then Hamil(i, j) := Vij(ni[i], mi[i], nj[j], mj[j])+(1/2)*(ni[i]^2+mi[i]^2)*Pi^2/L^2 end if end do end do; Eigenvec := Eigenvectors(Hamil, output = ['values', 'vectors']), Hamil end proc;
SigFigEi := proc (Location::integer, SigFig::integer, VecSize::integer) local values, Eig, i; global HamilMat, OptK; Eig := Vector(VecSize); for i from 2 to VecSize do Eig[i] := HamilMat(i)[1][Location]; if evalf(Eig(i), SigFig+1) = evalf(Eig(i-1), SigFig+1) then OptK := i; break end if end do; values := evalf(Eig[i], SigFig); return values, OptK end proc;
BasisFunc := proc (location) local ni, mi, func, i, j, p, N, res, BasisSol; global HamilMat, L, OptK; p := evalf(Pi); N := OptK^2; ni := Vector(N); mi := Vector(N); for i to N do for j to OptK do res := (i+OptK-j)/OptK; if type(res, integer) = true then ni[i] := j; mi[i] := res end if end do end do; func := Vector(N); for i to N do func[i] := HamilMat(OptK)[2][i][location]*sin(ni[i]*p*x/L)*sin(mi[i]*p*y/L) end do; BasisSol := unapply(add(func[i], i = 1 .. N), x, y); return plot3d(BasisSol(x, y), x = 0 .. L, y = 0 .. L), func end proc;
BasisFunc(1);
Error, (in Vector) dimension parameter is required for this form of initializer

Please Wait...