#this makes the gramian matrix for use in teh gram process #this is just he matrix of inner products. makeGram:=proc(T,lvl,funclist) local G, size, i, j; size:=nops(funclist); G:=matrix(size,size); for i from 1 to size do for j from 1 to size do G[i,j]:=discInnerProduct(T,lvl,funclist[i],funclist[j]); end do; end do; return(G); end; #not used. makeDiagInside:=proc(G) #Deprecated local E, i,e,eig,l; #E:=diag(evalf(eigenvals(G))); l:=[]; eig:=evalf(eigenvects(G)); for e in eig do for i from 1 to e[2] do l:=[op(l),e[1]]; end do; end do; print(l); E:=diag(op(l)); for i in indices(E) do E[op(i)]:=1/sqrt(E[op(i)]); #E[op(i)]:=4; end do; return(E); end; #used in makeA makeDiagOutside:=proc(G) local out, col, column, eig, e, i; column:=0; col:=[]; eig:=evalf(eigenvects(G)); for e in eig do for i from 1 to e[2] do col:=[op(col),e[3][i]]; column:=column + 1; end do; end do; out:=matrix(column, column, col); out:=transpose(out); return(out); end; #in the gram method, you want to find A such that A*G*A^t=I #this finds such an A #what this acutally is is D^(-1/2) where G=PDP^(-1) #G is diagnolizable cauze it's symmetric so the spetral #theorem applies. #where G is the gramian matrix makeA:=proc(T,lvl,funclist) local V, U, G, A, F, j; G:=makeGram(T,lvl,funclist); U:=makeDiagOutside(G); V:=inverse(U); F:=multiply(V, G, U); for j from 1 to nops(funclist) do F[j,j]:=1/sqrt(F[j,j]); end do; A:=multiply(U,F,V); return A; end; #once you have A gthe gram method tells you how to make an orthonoraml #basis. this uses makeA to do just that makeOrtho:=proc(T, lvl, funclist, startfunc) local A, i, j; A:=makeA(T, lvl, funclist); for i from 1 to nops(funclist) do clearFunc(T,lvl,startfunc + i -1); for j from 1 to nops(funclist) do funcSumWithConstant(T,lvl,A[i,j],startfunc + i -1,funclist[j] ,startfunc + i -1); end do; end do; return(startfunc + nops(funclist)); end;