recursive def of legendre polynomial



Oops. sorry.  Here is the recursive way.

(out5) false
(%i6) p[n](x) := if equal(n,0) then 1 else if equal(n,1) then x else ((2*n-1)/n)*x*p[n-1](x) - ((n-1)/n)*p[n-2](x);

(out6) p[n](x):=if equal(n,0) then 1 else (if equal(n,1) then x else (2*n-1)/n*x*p[n-1](x)-(n-1)/n*p[n-2](x))
(%i7) p[3](x);

(out7) 5*x*(3*x^2/2-1/2)/3-2*x/3
(%i8)


----- Original Message ----- 
From: "Richard Fateman" <fateman at cs.berkeley.edu>
To: "maxima mailing list" <maxima at math.utexas.edu>
Sent: Sunday, August 09, 2009 3:33 PM
Subject: Re: [Maxima] recursive def of legendre polynomial



> I wrote...
>
>
> a recursive version is not nearly as much fun.  it would look like p(n,x):= if n=0 then 1 else if n=1 then x else ...
>   

Richard Hennessy's is a Rodriguez formula for the same polynomials, and 
is not recursive, but certainly works too.

If you are doing a lot of computations with them, try to simplify the 
polynomials
when you create them, instead of later.


_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima