Gram-Schmidt orthonormalization and orthogonalization
Load the linear algebra package (library)
<<LinearAlgebra`Orthogonalization`
![[Graphics:Images/GramSchmidt_gr_1.gif]](Images/GramSchmidt_gr_1.gif)
![[Graphics:Images/GramSchmidt_gr_2.gif]](Images/GramSchmidt_gr_2.gif)
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}
![[Graphics:Images/GramSchmidt_gr_3.gif]](Images/GramSchmidt_gr_3.gif)
orthonormalFunctions = GramSchmidt[functions,
InnerProduct ->
(Integrate[#1 #2,{x,-1,1}]&)]//Simplify
![[Graphics:Images/GramSchmidt_gr_4.gif]](Images/GramSchmidt_gr_4.gif)
Check for orthonormality
![[Graphics:Images/GramSchmidt_gr_5.gif]](Images/GramSchmidt_gr_5.gif)
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
![[Graphics:Images/GramSchmidt_gr_6.gif]](Images/GramSchmidt_gr_6.gif)
![[Graphics:Images/GramSchmidt_gr_7.gif]](Images/GramSchmidt_gr_7.gif)
Equivalent two-step process: first create orthogonal but not normalized functions from a given set of linearly independent functions, then normalize them
![[Graphics:Images/GramSchmidt_gr_8.gif]](Images/GramSchmidt_gr_8.gif)
![[Graphics:Images/GramSchmidt_gr_9.gif]](Images/GramSchmidt_gr_9.gif)
Check for orthonormality
![[Graphics:Images/GramSchmidt_gr_10.gif]](Images/GramSchmidt_gr_10.gif)
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
![[Graphics:Images/GramSchmidt_gr_15.gif]](Images/GramSchmidt_gr_15.gif)
Check that we get the same result as simuultaneous orthogonalization and normalization
![[Graphics:Images/GramSchmidt_gr_16.gif]](Images/GramSchmidt_gr_16.gif)
![[Graphics:Images/GramSchmidt_gr_17.gif]](Images/GramSchmidt_gr_17.gif)
Converted by Mathematica
November 22, 2005