# Question:Legendre Polynomials

## Question:Legendre Polynomials

Maple 15

I want to write a code to generate Legendre Polynomials using the Gram-Schmidt Process. I have no experience with programing. Here is how the process should work:

Given "(f) = {f[0]=1, f[1]=x , f[2]=x^(2) , f[3]=x^(3) , ... , f[n]=x^(n)} "

Find the Legendre Polynomials: "{P[0] , P[1] , P[2] , P[3] , ... , P[n]}"

First,  P[0]=f[0]=1

then, the rest are defined recursively by

P[1]=f[1]-(()/())*P[0] = x

P[2]=f[2]-(()/())*P[0]-(()/())*P[1] = x^2-1/3

P[3]=f[3]-(()/())*P[0]-(()/())*P[1]-(()/())*P[2] = x^3-(3/5)x

P[4]=f[4]-(()/())*P[0]-(()/())*P[1]-(()/())*P[2]-(()/())*P[3] = x^4-(6/7)x^2+3/35

.

.

.

P[n]=f[n]-(()/())*P[0]-(()/())*P[1]-...-(()/())*P[i]-...-(()/())*P[n-1]

where in general, (()/())*P[i]= (int(f[n]*P[i], x = -1 .. 1))/(int(P[i]*P[i], x = -1 .. 1))*P[i], for all i=0,1,2,...,n-1

ie. the inner product  = int(p(x)*q(x), x = -1 .. 1).

Can anyone help me write a code to generate the Legendre polynomials?

Thanks,