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); |
> | an:=(1/L)*Int(f(x)*cos(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); |
> | 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); |
> | an:=(2/L)*Int(f(x)*cos(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); |
> | 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; |
> | fo:=paritonjatko(f);fe:=parillinenjatko(f); |
> | plot(fo);plot(fe); |
> | fo2J:=JJ(fo,-2..2);fe2J:=JJ(fe,-2..2); |
> | plot(fo2J,-4..4); |
> | plot(fe2J,-4..4); |
Kosinisarja:
> | L:=2: |
> | a0:=(1/L)*Int(f(x),x=0..L);a0:=value(%); |
> | an:=(2/L)*Int(f(x)*cos(n*Pi*x/L),x=0..L);an:=value(an); |
> | an:=trigsiev(an,n); |
> | seq(an,n=1..10); |
> | evalf(%); |
> |
> |
> | 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]); |
> | plot([Cosasumma(x,10),fe2J(x)],x=-4..4,color=[red,blue],numpoints=100); |
> | Cosasumma(x,10); |
> |
> |
Sinisarja
> | bn:=(2/L)*Int(f(x)*sin(n*Pi*x/L),x=0..L);bn:=value(bn); |
> | bn:=trigsiev(bn,n); |
> | seq(bn,n=1..10);evalf(%); |
> | 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); |
> | plot([Sosasumma(x,50),fo2J(x)],x=-4..4,color=[red,blue],numpoints=100); |
> |
> |