legendre2.mws

>    restart;with(plots):

>    a:=-100; b:=100;

>    affine:=x->(2*x+b+a)/(b-a):

Warning, the name changecoords has been redefined

>    F:=(p,x)->(2*LegendreP(0,x)/3)-2*sum('LegendreP(k,x)/((2*k-1)*(2*k+3))','k'=1..p);

F := proc (p, x) options operator, arrow; 2/3*LegendreP(0,x)-2*sum('LegendreP(k,x)/(2*k-1)/(2*k+3)',('k') = 1 .. p) end proc

>    u:=(p,x)->sqrt((1-x)/2)-F(p,x);

u := proc (p, x) options operator, arrow; sqrt(1/2-1/2*x)-F(p,x) end proc

>    plot([seq(u(i,x),i=1..10)],x=-1..1,y=-0.05..0.05);

[Maple Plot]

>    f:=x->exp(x);km:=20;

>    for n from 0 to km do c[n]:=evalf((n+1/2)*int(f(u)*LegendreP(n,u), u=-1..1)); od:

>   

>    F:=(p,x)->sum('c[k]*LegendreP(k,x)', 'k'=0..p);

F := proc (p, x) options operator, arrow; sum('c[k]*LegendreP(k,x)',('k') = 0 .. p) end proc

>    plot([seq(exp(x)-F(i,x),i=5..7)],x=-1..1,color=black);

[Maple Plot]

>    evalf(F(0.1));evalf(exp(0.1));

>    plot(F(x), x=-1..1,y=-5..5);

>   

[Maple Plot]

>   

Maple TM is a registered trademark of Waterloo Maple Inc.
Math rendered by WebEQ