math Legendre problem

Initial conditions p(0)=1 and p(1)=x , we also have that p(n+1)=((2*n+1)*x*p(n)-n*p(n-1))/(n+1).
As we all know, matlab cannt start from p(0), therefor i do this :
p(1)=1, p(2)=x and p(n)=((2*n-1)*x*p(n-1)-(n-1)*p(n-2))/n
but i DON'T take the same results and i don't know the reason !! As you see i am working with Legendre Polynomials !!
Thanks !!

 채택된 답변

Geoff
Geoff 2012년 4월 1일

0 개 추천

That's almost right, but wherever you had p(n) etc, you shouldn't adjust n. You should only have subtracted 1 from the instances of n that are on their own. So change all your p(??) bits back to their original values and it should work.

댓글 수: 4

George
George 2012년 4월 1일
i think i did it but still doesn't work. i propably missunderstood what you 've told me to do.. can you explain it to me again please ?
Geoff
Geoff 2012년 4월 1일
Hmmm I might have done this backwards. It depends whether you define 'n' with its original meaning, or if you use a new 'n' that means something else!
Let's go with keeping the original meaning. In that case, your original formula is correct except for anywhere it indexes into 'p'. So you would just add 1 to 'n' inside any of the p-vector references, and don't touch it anywhere else.
You are trying to preserve the meaning of 'n', but change the indexing of 'p'.
George
George 2012년 4월 1일
can you please write down the formula ??? Thanks !!
George
George 2012년 4월 1일
p(k+2) = ((2*k+1)*x*p(k+1) - (k)*p(k))/(k+1) ;
i think i've got it right now !!!! THANKS !!!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Polynomials에 대해 자세히 알아보기

질문:

2012년 4월 1일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by