If you want to evaluate legendre polynomials at a floating-point number
point, you are doing it a very poor way.
You should compute the value by using the 3-term recurrence relation.
Why?
A. It it faster
B. It is far more accurate
L(j,x):= if j=0 then 1 else if j=1 then x else
1/j*((2*j-1)*x*L(j-1,x)-(j-1)*L(j-2,x));
If you just want to look at a legendre polynomial at point "x", then
evaluate the recurrence there. L(8,rat(x)) for example.
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of Martin DRUON
> Sent: Saturday, June 16, 2007 11:01 AM
> To: maxima at math.utexas.edu
> Subject: list of functions
>
> hi,
>
> I would like to create a list of Legendre polynomials... so,
> I tried this :
>
> list_of_poly(degree):=(
> load(orthopoly),
> block([l:[]],
> for i:0 thru degree do (
> l:cons(legendre_p(i,x),l)
> ),
> l:reverse(l),
> return(l)
> )
> )$
>
> but I can't evaluate polynomials :
>
> l:list_of_poly(3)
> l[2](5)
>
> doesn't work (has I want !!)
>
> it returns x(5) but I want 5 :
> l[2] holds polynomial "x" -> when I write l[2](5) I would like 5
>
>
> I also tried :
>
> list_of_poly2(degree):=(
> load(orthopoly),
> block([l:[]],
> for i:0 thru degree do (
> l:cons(lambda([x], legendre_p(i,x)),l)
> ),
> l:reverse(l),
> return(l)
> )
> )$
>
> now, I can evaluate polynomials but "i" is not evaluate :
>
> l:list_of_poly2(3)
> l[2](5)
>
> returns "legendre_p(i, 5)"
>
>
> How I can store functions in lists and evaluate them ?
>
> Thanks
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>