Fourier-sarjat, L/Fsarjat.mws

26.11.04  HA

Apufunktioita: JJ, trigsiev

>    restart:

>    with(plots):

Warning, the name changecoords has been redefined

>    #read("/p/edu/mat-1.414/maple/v302.mpl"):

>    read("c:\\usr\\heikki\\maple\\v302.mpl"):

>    #read("/home/apiola/opetus/peruskurssi/v2-3/maple/v302.mpl"):

Fourier-sarjan kertoimet

>    f:='f':

>    a0:=(1/(2*L))*Int(f(x),x=-L..L);

a0 := 1/2*1/L*Int(f(x),x = -L .. L)

>    an:=(1/L)*Int(f(x)*cos(n*x),x=-L..L);

an := 1/L*Int(f(x)*cos(n*x),x = -L .. L)

>    bn:=(1/L)*Int(f(x)*sin(n*x),x=-L..L);

bn := 1/L*Int(f(x)*sin(n*x),x = -L .. L)

>    sarja:='a0'+Sum('an'*cos(n*Pi*x/L)+'bn'*sin(n*Pi*x/L),n=1..infinity);

sarja := a0+Sum(an*cos(n*Pi*x/L)+bn*sin(n*Pi*x/L),n = 1 .. infinity)

>    osasumma:=(x,N)->a0+add(an*cos(n*Pi*x/L)+bn*sin(n*Pi*x/L),n=1..N):

>   

Esim: Parillinen ja pariton laajennus

>    restart:

>    with(plots):

Warning, the name changecoords has been redefined

>    #read("/p/edu/mat-1.414/maple/v302.mpl"):

>    read("c:\\usr\\heikki\\maple\\v302.mpl"):

>    #read("/home/apiola/opetus/peruskurssi/v2-3/maple/v302.mpl"):

>    f:='f':

>    a0:=(1/(L))*Int(f(x),x=0..L);

a0 := 1/L*Int(f(x),x = 0 .. L)

>    an:=(2/L)*Int(f(x)*cos(n*x),x=0..L);

an := 2/L*Int(f(x)*cos(n*x),x = 0 .. L)

>    bn:=(1/L)*Int(f(x)*sin(n*x),x=0..L);

bn := 1/L*Int(f(x)*sin(n*x),x = 0 .. L)

>    cossarja:='a0'+Sum('an'*cos(n*Pi*x/L),n=1..infinity);

cossarja := a0+Sum(an*cos(n*Pi*x/L),n = 1 .. infinity)

>    sinsarja:='a0'+Sum('an'*sin(n*Pi*x/L),n=1..infinity);

sinsarja := a0+Sum(an*sin(n*Pi*x/L),n = 1 .. infinity)

>    #Cosasumma:=(x,N)->a0+add(an*cos(n*Pi*x/L),n=1..N):

>    #Sosasumma:=(x,N)->add(bn*sin(n*Pi*x/L),n=1..N):

>   

f(x)=x^3

>    f:=x->x^3;

f := proc (x) options operator, arrow; x^3 end proc

>    fo:=paritonjatko(f);fe:=parillinenjatko(f);

fo := proc (x) options operator, arrow; piecewise(0 < x,x^3,x < 0,x^3) end proc

fe := proc (x) options operator, arrow; piecewise(0 < x,x^3,x < 0,-x^3) end proc

>    plot(fo);plot(fe);

[Maple Plot]

[Maple Plot]

>    fo2J:=JJ(fo,-2..2);fe2J:=JJ(fe,-2..2);

fo2J := proc (x::algebraic) local y; y := floor(1/4*x+1/2); fo(x-4*y) end proc

fe2J := proc (x::algebraic) local y; y := floor(1/4*x+1/2); fe(x-4*y) end proc

>    plot(fo2J,-4..4);

[Maple Plot]

>    plot(fe2J,-4..4);

[Maple Plot]

Kosinisarja:

>    L:=2:

>    a0:=(1/L)*Int(f(x),x=0..L);a0:=value(%);

a0 := 1/2*Int(x^3,x = 0 .. 2)

a0 := 2

>    an:=(2/L)*Int(f(x)*cos(n*Pi*x/L),x=0..L);an:=value(an);

an := Int(x^3*cos(1/2*n*Pi*x),x = 0 .. 2)

an := 16*(n^3*Pi^3*sin(n*Pi)+3*n^2*Pi^2*cos(n*Pi)-6*cos(n*Pi)-6*n*Pi*sin(n*Pi)+6)/n^4/Pi^4

>    an:=trigsiev(an,n);

an := 48*(2+n^2*Pi^2*(-1)^n+2*(-1)^(1+n))/n^4/Pi^4

>    seq(an,n=1..10);

48*(4-Pi^2)/Pi^4, 12/Pi^2, 16/27*(4-9*Pi^2)/Pi^4, 3/Pi^2, 48/625*(4-25*Pi^2)/Pi^4, 4/3/Pi^2, 48/2401*(4-49*Pi^2)/Pi^4, 3/4/Pi^2, 16/2187*(4-81*Pi^2)/Pi^4, 12/25/Pi^2
48*(4-Pi^2)/Pi^4, 12/Pi^2, 16/27*(4-9*Pi^2)/Pi^4, 3/Pi^2, 48/625*(4-25*Pi^2)/Pi^4, 4/3/Pi^2, 48/2401*(4-49*Pi^2)/Pi^4, 3/4/Pi^2, 16/2187*(4-81*Pi^2)/Pi^4, 12/25/Pi^2

>    evalf(%);

-2.892348222, 1.215854203, -.5160454659, .3039635508, -.1913829628, .1350949114, -.9843246786e-1, .7599088770e-1, -.5974176091e-1, .4863416813e-1
-2.892348222, 1.215854203, -.5160454659, .3039635508, -.1913829628, .1350949114, -.9843246786e-1, .7599088770e-1, -.5974176091e-1, .4863416813e-1

>   

>   

>    Cosasumma:=(x,N)->a0+add(an*cos(n*Pi*x/L),n=1..N):

>    plot([Cosasumma(x,10),fe(x)],x=-2..2,color=[red,blue]);

[Maple Plot]

>    plot([Cosasumma(x,10),fe2J(x)],x=-4..4,color=[red,blue],numpoints=100);

[Maple Plot]

>    Cosasumma(x,10);

2+48*(4-Pi^2)/Pi^4*cos(1/2*Pi*x)+12/Pi^2*cos(Pi*x)+16/27*(4-9*Pi^2)/Pi^4*cos(3/2*Pi*x)+3/Pi^2*cos(2*Pi*x)+48/625*(4-25*Pi^2)/Pi^4*cos(5/2*Pi*x)+4/3*1/Pi^2*cos(3*Pi*x)+48/2401*(4-49*Pi^2)/Pi^4*cos(7/2*P...
2+48*(4-Pi^2)/Pi^4*cos(1/2*Pi*x)+12/Pi^2*cos(Pi*x)+16/27*(4-9*Pi^2)/Pi^4*cos(3/2*Pi*x)+3/Pi^2*cos(2*Pi*x)+48/625*(4-25*Pi^2)/Pi^4*cos(5/2*Pi*x)+4/3*1/Pi^2*cos(3*Pi*x)+48/2401*(4-49*Pi^2)/Pi^4*cos(7/2*P...
2+48*(4-Pi^2)/Pi^4*cos(1/2*Pi*x)+12/Pi^2*cos(Pi*x)+16/27*(4-9*Pi^2)/Pi^4*cos(3/2*Pi*x)+3/Pi^2*cos(2*Pi*x)+48/625*(4-25*Pi^2)/Pi^4*cos(5/2*Pi*x)+4/3*1/Pi^2*cos(3*Pi*x)+48/2401*(4-49*Pi^2)/Pi^4*cos(7/2*P...

>   

>   

Sinisarja

>    bn:=(2/L)*Int(f(x)*sin(n*Pi*x/L),x=0..L);bn:=value(bn);

bn := Int(x^3*sin(1/2*n*Pi*x),x = 0 .. 2)

bn := -16*(n^3*Pi^3*cos(n*Pi)-3*n^2*Pi^2*sin(n*Pi)+6*sin(n*Pi)-6*n*Pi*cos(n*Pi))/n^4/Pi^4

>    bn:=trigsiev(bn,n);

bn := -16/n^3/Pi^3*(n^2*Pi^2*(-1)^n+6*(-1)^(1+n))

>    seq(bn,n=1..10);evalf(%);

-16/Pi^3*(-Pi^2+6), -2/Pi^3*(4*Pi^2-6), -16/27/Pi^3*(-9*Pi^2+6), -1/4/Pi^3*(16*Pi^2-6), -16/125/Pi^3*(-25*Pi^2+6), -2/27/Pi^3*(36*Pi^2-6), -16/343/Pi^3*(-49*Pi^2+6), -1/32/Pi^3*(64*Pi^2-6), -16/729/Pi^...
-16/Pi^3*(-Pi^2+6), -2/Pi^3*(4*Pi^2-6), -16/27/Pi^3*(-9*Pi^2+6), -1/4/Pi^3*(16*Pi^2-6), -16/125/Pi^3*(-25*Pi^2+6), -2/27/Pi^3*(36*Pi^2-6), -16/343/Pi^3*(-49*Pi^2+6), -1/32/Pi^3*(64*Pi^2-6), -16/729/Pi^...

1.996810874, -2.159460676, 1.582980604, -1.224862243, .9938224572, -.8344923474, .7185387853, -.6305726097, .5616371264, -.5061996706
1.996810874, -2.159460676, 1.582980604, -1.224862243, .9938224572, -.8344923474, .7185387853, -.6305726097, .5616371264, -.5061996706

>    Sosasumma:=(x,N)->add(bn*sin(n*Pi*x/L),n=1..N):

>    plot([Sosasumma(x,10),fo2J(x)],x=-4..4,color=[red,blue],numpoints=100);

[Maple Plot]

>    plot([Sosasumma(x,50),fo2J(x)],x=-4..4,color=[red,blue],numpoints=100);

[Maple Plot]

>   

>