May 13, 2010

P[n_,x_] := Expand[(1/(2^n*n!))D[(x^2-1)^n,{x,n}]]

expr1 = Series[(1-2x*t+t^2)^(-1/2),{t,0,10}]

expr2 = Normal[expr1]

?Collect

expr3 = Collect[ expr2,t,Expand]

Do[ Q[n_,x_] := Coefficient[expr3,t,n],{n,0,10} ]             (* Need delayed evaluation. *)

Q[0,x]

Q[1,x]

Q[2,x]

Table[{n, P[n,x],Q[n,x]},{n,0,10}]  //  TableForm

Table[{n, Expand[ P[n,x]-Q[n,x]]}, {n,0,10}]

_____________________________________________________________________________

Table[ Integrate[P[m,x]*P[n,x],{x,-1,1}],{m,0,10},{n,0,10}]  // TableForm

Table[ {n, Integrate[ P[n,x]*P[n,x],{x,-1,1}] - 2/(2n+1)} , {n,0,12}]

f[x_] = x^2+x+1

Do[ a[n] = ((2n+1)/2)Integrate[f[x]*P[n,x],{x,-1,1}], {n,0,2}]

Sum[a[i]*P[i,x],{i,0,2}]  //  Expand

_____________________________________________________________________________

f[x_] = 5-10 x-54 (x^2)+20 (x^3)+70 (x^4)

Integrate[f[x]*P[0,x],{x,-1,1}]

Do[a[i] = ((2i+1)/2)Integrate[f[x]*P[i,x],{x,-1,1}],{i,0,4}]

a[0]

Table[{i,a[i]},{i,0,4}]  //  TableForm

f[x]-Sum[a[i]*P[i,x],{i,0,4}]  //  Expand

________________________________________________________________

identity[n_] := Expand[(n)P[n,x]- (2n-1)x*P[n-1,x]+(n-1)*P[n-2,x] ]

Table[{n, identity[n]},{n,2,20}]

__________________________________________________________________

R[0,x] = 1

R[1,x] = x

R[n_,x_] := Expand[ (1/n)( (2n-1)x*R[n-1,x] - (n-1)R[n-2,x] ) ] /;  n ≥2

{P[2,x], R[2,x]}

{P[3,x], R[3,x]}

Table[{n, Expand[R[n,x] - P[n,x]]},{n,0,10}]

____________________________________________________________________

T[n_,x_] := Expand[ Sqrt[(2n+1)/2]*P[n,x]]

Table[ Integrate[T[m,x]*T[n,x],{x,-1,1}],{m,0,10},{n,0,10}]  //  TableForm

________________________________________________________________