How can I design a program to construct Legendre polynomials in Maple 13

439 Views Asked by At

I'm a new user of Maple 13. I'm trying to design a program to illustration the progress of construct Legendre polynomials for my friends by using Maple. I've search on Google and found an algorithm for Mathmetica in here Construct Legendre polynomials in Mathmetica, but I don't know how to write it in Maple.

Can someone help me some basic steps?

1

There are 1 best solutions below

0
On

orthopoly[P](n,x) is the $n$'th Legendre polynomial evaluated at $x$.

If you want to construct them yourself, you could use the recurrence

$$ \eqalign{P_{{n}} \left( x \right) &={\frac { \left( 2\,n-1 \right) xP_{{n-1}} \left( x \right) }{n}}-{\frac {\left( n-1 \right) P_{{n-2}} \left( x \right) }{n }}\cr P_0(x) &= 1,\; P_1(x) = x\cr} $$

For example (to have the first 20 as expressions in $x$)

P[0]:= 1:
P[1]:= x:
for n from 2 to 20 do
   P[n]:= expand((2*n-1)*x*P[n-1]/n -(n-1)*P[n-2]/n) 
end do;

Or if you prefer to define them as functions:

P[0]:= x -> 1;
P[1]:= x -> x;
for n from 2 to 20 do
   P[n]:= unapply(expand((2*n-1)*x*P[n-1](x)/n - (n-1)*P[n-2](x)/n), x)
end do;