Gram-Schmidt Maple Code The Maple code that appears below should be copied into a Maple session and executed. That will cause the programs (in Maple called procedures) to be defined and therefore available for use. ======================================================================= # f[0],f[1],...,f[n] are a set of nonorthogonal functions (input). # The f[i] must be functions of a variable named x. # F[0],F[1],...,F[n] are orthonormal functions (output) produced # by applying the Gram-Schmidt process to the f[i]. # The index number of the last function is n (input). # When called, F is the result of this procedure; its elements are # also printed by the procedure. Schmidt:=proc(f,n) local T,i,j,F; for i from 0 to n do T:=f[i]; if i <> 0 then T:=T-add(F[j]*S(F[j],T),j=0.. i-1) fi; F[i]:=sort(T)/sqrt(S(T,T)); print(F[i]) od; F end; # Subprogram called by Schmidt S:=proc(u,v) global w,a1,a2; int(u*w*v,x=a1..a2) end; # These settings are for range 0..1 and unit weight a1:=0; a2:=1; w:=1; # This procedure makes the expansion of f (which must be an expression # involving the variable x) in the orthonormal functions in the array # F, using F[0] through F[n]. When called, the result of the procedure # is the requested expansion, simplified according to Maple's rules. OrthExp:=proc(g,F,n) local j; sum('evalf(S(F[j],g)*F[j])',j=0..n) end; ======================================================================= After having defined the above procedures, enter into your Maple session some input to use with it, such as > f[0]:=1; > f[1]:=x; > ... Then run the procedure by entering (if n=4) > F:=Schmidt(f,4); The array F will now have been created. You can check by entering, for example > F[4]; The content of F[4] should be displayed. You can use a set of orthonormal functions F[i] to expand an expression g (in the variable x) by entering something like > G:=OrthExp(g,F,n); where n is the index of the last member of F. This will cause the expansion to be saved in G, from which it can be plotted or used for other purposes.