Gram-Schmidt orthonormalization and orthogonalization
Load the linear algebra package (library)
<<LinearAlgebra`Orthogonalization`
Orthonormalize a typical set of independent functions (MMa treats a set as a list inside curly braces.)
Integrals range from -1 to +1 in this example - make the functions and integral ranges whatever you like (as long as the integrals exist).
functions = {1, x, x^2, x^3, x^4}
orthonormalFunctions = GramSchmidt[functions,
InnerProduct ->
(Integrate[#1 #2,{x,-1,1}]&)]//Simplify
Check for orthonormality
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
0
|
1
|
Show what the orthonormalized functions look like
Equivalent two-step process: first create orthogonal but not normalized functions from a given set of linearly independent functions, then normalize them
Check for orthonormality
2
|
0
|
0
|
0
|
0
|
0
|
|
0
|
0
|
0
|
0
|
0
|
|
0
|
0
|
0
|
0
|
0
|
|
0
|
0
|
0
|
0
|
0
|
|
Now normalize the orthogonal functions
normalizedFunctions = Table[Normalize[orthoFunctions[[i]],
InnerProduct ->
(Integrate[#1 #1,{x,-1,1}]&)],{i,1,5}]//Simplify
Check that we get the same result as simuultaneous orthogonalization and normalization
Converted by Mathematica
November 22, 2005