Hi am trying to prove using the recursive formula that the legendre polynomial P3(x)=(1/2)*(5x^3 - 3x) .......(1)
This is the recursive formula
Pk+1=(1/k+1)*((2*k+1)*x*P2-k*P1)
where P2=(1/2)(3x^2 - 1) and P1=x
we have chosen k=2 so it gives Pk+1 = P3.
Everytime I try to evaluate this by hand, I dont get equation (1), which is what I need, can someone help me on this.
I even tried matlab which gave an ans = 45/4*x^3-27/4*x, which is still not (1).
Hi, I am having trouble getting this legendre function to work in Matlab now. I am suppose to create a for-loop containing the recursion equation to create a vector called P, containing simplified symbolic formulae for the legendre polynomials from degree 1 up to degree 10. firstly I included the first two degree
here is my matlab code of I tried to do:
syms x k
x=linspace(-1,1,5);
P(1)=x;
P(2)=0.5*(3*x^2-1);
for k=1:9
P(k+1)=(1/k+1)*((2*k+1)*x*P(k)-k*P(k-1));
end
I keep getting this error from Matlab:
??? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> legendrepoly at 4
P(1)=x;
Well I don't have the symbolic tool boxed, so I don't know much about symbolic operations in Matlab.
But: you want x to be a symbolic variable, but you have assigned it to a numeric array (which may be arbitrary precision or floating point; I don't know) which I'm pretty sure is nonsense.
(and note opalg's comment about loop indices)
RonL