Previous Up Next

2.49.4  Gramschmidt orthonormalization : gramschmidt

gramschmidt takes one or two arguments :

gramschmidt returns an orthonormal basis for this scalar product.
Input :

normal(gramschmidt([[1,1,1],[0,0,1],[0,1,0]]))

Or input :

normal(gramschmidt([[1,1,1],[0,0,1],[0,1,0]],dot))

Output :

[[(sqrt(3))/3,(sqrt(3))/3,(sqrt(3))/3],[(-(sqrt(6)))/6,(-(sqrt(6)))/6,(sqrt(6))/3],[(-(sqrt(2)))/2,(sqrt(2))/2,0]]

Example
We define a scalar product on the vector space of polynomials by:

P.Q=
1


−1
P(x).Q(x)dx 

Input :

gramschmidt([1,1+x],(p,q)->integrate(p*q,x,-1,1))

Or define the function p_scal, input :
p_scal(p,q):=integrate(p*q,x,-1,1)
then input :

gramschmidt([1,1+x],p_scal)

Output :

[1/(sqrt(2)),(1+x-1)/sqrt(2/3)]

Previous Up Next