fourier1.mws

Some Fourier Series Expansions

Example 3 (Lecture)

>    restart:N:=5:p:=2:A:=-2:B:=2:pleft:=-5:pright:=5:with(plots):

>    f(t):=piecewise(t<A,0, t>A and t<B,4-t^2,t>B ,0);

Warning, the name changecoords has been redefined

f(t) := PIECEWISE([0, t < -2],[4-t^2, -t < 2 and t < 2],[0, 2 < t])

>   

>    a[0]:=1/p*int(f(t),t=-2..2);

a[0] := 16/3

>    a[n]:=1/p*int(f(t)*cos(n*Pi*t/p),t=-2..2); b[n]:=1/p*int(f(t)*sin(n*Pi*t/p),t=-2..2);

a[n] := -16*(n*Pi*cos(n*Pi)-sin(n*Pi))/n^3/Pi^3

b[n] := 0

>    b[n] := 0;

b[n] := 0

>    fs[N](t):=1/2*a[0]+ sum(a[n]*cos(n*Pi*t/p)+b[n]*sin(n*Pi*t/p),n=1..N);

fs[5](t) := 8/3+16/Pi^2*cos(1/2*Pi*t)-4/Pi^2*cos(Pi*t)+16/9*1/Pi^2*cos(3/2*Pi*t)-1/Pi^2*cos(2*Pi*t)+16/25*1/Pi^2*cos(5/2*Pi*t)

>   

>    fpe:=proc(x) local y;y:=x; while y < A do y:=y+2*p;od; while y > B do y:=y-2*p;od;evalf(subs(t=y,f(t)));end;

fpe := proc (x) local y; y := x;  while y < A do y := y+2*p end do;  while B < y do y := y-2*p end do; evalf(subs(t = y,f(t))) end proc

>   

>    Pf:=plot(fpe,pleft..pright,numpoints=200):Pfs:=plot(fs[N](t),t=pleft..pright,color=blue,numpoints=500):

>    display(Pf,Pfs);

[Maple Plot]

>   

>   

>   

Example 4 (Lecture)

>    restart:N:=5:p:=1:A:=0:B:=2:pleft:=-5:pright:=5:with(plots):

Warning, the name changecoords has been redefined

>    f(t):=piecewise(t<A,0, t>A and t < 1,1+t^2, t>1 and t<B, 3-t,t>B ,0);plot(f(t),t=-5..5);

f(t) := PIECEWISE([0, t < 0],[1+t^2, -t < 0 and t < 1],[3-t, -t < -1 and t < 2],[0, 2 < t])

[Maple Plot]

>   

>    a[0]:=1/p*int(f(t),t=A..B);

a[0] := 17/6

>    a[n]:=1/p*int(f(t)*cos(n*Pi*t/p),t=A..B); b[n]:=1/p*int(f(t)*sin(n*Pi*t/p),t=A..B);

a[n] := (2*n^2*Pi^2*sin(n*Pi)*cos(n*Pi)+3*n*Pi*cos(n*Pi)-2*n*Pi*cos(n*Pi)^2+n*Pi-2*sin(n*Pi))/n^3/Pi^3

b[n] := -(2*n^2*Pi^2*cos(n*Pi)^2-2*n^2*Pi^2+2*n*Pi*sin(n*Pi)*cos(n*Pi)-3*n*Pi*sin(n*Pi)-2*cos(n*Pi)+2)/n^3/Pi^3

>    fs[N](t):=1/2*a[0]+ sum(a[n]*cos(n*Pi*t/p)+b[n]*sin(n*Pi*t/p),n=1..N);

fs[5](t) := 17/12-4/Pi^2*cos(Pi*t)-4/Pi^3*sin(Pi*t)+1/2*1/Pi^2*cos(2*Pi*t)-4/9*1/Pi^2*cos(3*Pi*t)-4/27*1/Pi^3*sin(3*Pi*t)+1/8*1/Pi^2*cos(4*Pi*t)-4/25*1/Pi^2*cos(5*Pi*t)-4/125*1/Pi^3*sin(5*Pi*t)

>    fpe:=proc(x) local y;y:=x; while y < A do y:=y+2*p;od; while y > B do y:=y-2*p;od;evalf(subs(t=y,f(t)));end;

fpe := proc (x) local y; y := x;  while y < A do y := y+2*p end do;  while B < y do y := y-2*p end do; evalf(subs(t = y,f(t))) end proc

>   

>    Pf:=plot(fpe,pleft..pright,numpoints=200):Pfs:=plot(fs[N](t),t=pleft..pright,color=blue,numpoints=500):

>    display(Pf,Pfs);

[Maple Plot]

>   

>   

Problem 8.4:3

>    restart:N:=5:p:=2:A:=0:B:=2*p:pleft:=-5:pright:=5:with(plots):

Warning, the name changecoords has been redefined

>    f(t):=piecewise(t<A,0, t>A and t < p,1-t,t>p and t<2*p, 0 ,t>B ,0);plot(f(t),t=-5..5);

f(t) := PIECEWISE([0, t < 0],[1-t, -t < 0 and t < 2],[0, -t < -2 and t < 4],[0, 4 < t])

[Maple Plot]

>   

>    a[0]:=1/p*int(f(t),t=A..B);

a[0] := 0

>    a[n]:=1/p*int(f(t)*cos(n*Pi*t/p),t=A..B); b[n]:=1/p*int(f(t)*sin(n*Pi*t/p),t=A..B);

a[n] := -(n*Pi*sin(n*Pi)-2+2*cos(n*Pi))/n^2/Pi^2

b[n] := (n*Pi*cos(n*Pi)+n*Pi-2*sin(n*Pi))/n^2/Pi^2

>    fs[N](t):=1/2*a[0]+ sum(a[n]*cos(n*Pi*t/p)+b[n]*sin(n*Pi*t/p),n=1..N):

>    fpe:=proc(x) local y;y:=x; while y < A do y:=y+2*p;od; while y > B do y:=y-2*p;od;evalf(subs(t=y,f(t)));end;

fpe := proc (x) local y; y := x;  while y < A do y := y+2*p end do;  while B < y do y := y-2*p end do; evalf(subs(t = y,f(t))) end proc

>   

>    Pf:=plot(fpe,pleft..pright,numpoints=200):Pfs:=plot(fs[N](t),t=pleft..pright,color=blue,numpoints=500):

>    display(Pf,Pfs);

[Maple Plot]

>   

>   

>   

Problem 8.2:6

>    restart:N:=5:p:=1/2*(B-A):A:=0:B:=2*evalf(Pi):pleft:=-10:pright:=8:with(plots):

Warning, the name changecoords has been redefined

>    f(t):=piecewise(t<A,0, t>A and t < 2*Pi/3,0, t>2*Pi/3 and t <4*Pi/3, 1, t > 4*Pi/3 and t < B, 2, t>B, 0);plot(f(t),t=0..8);

f(t) := PIECEWISE([0, t < 0],[0, -t < 0 and t-2/3*Pi < 0],[1, -t+2/3*Pi < 0 and t-4/3*Pi < 0],[2, -t+4/3*Pi < 0 and t < 6.283185308],[0, 6.283185308 < t])

[Maple Plot]

>   

>    a[0]:=1/p*int(f(t),t=A..B);

a[0] := 2.000000000

>    a[n]:=1/p*int(f(t)*cos(n*Pi*t/p),t=A..B); b[n]:=1/p*int(f(t)*sin(n*Pi*t/p),t=A..B);

a[n] := .3183098861*(2.*sin(6.283185308*n)-1.*sin(4.188790205*n)-1.*sin(2.094395102*n))/n

b[n] := -.3183098861*(2.*cos(6.283185308*n)-1.*cos(4.188790205*n)-1.*cos(2.094395102*n))/n

>    fs[N](t):=1/2*a[0]+ sum(a[n]*cos(n*Pi*t/p)+b[n]*sin(n*Pi*t/p),n=1..N);

fs[5](t) := 1.000000000+.4774648292e-9*cos(.9999999999*t)-.9549296583*sin(.9999999999*t)+.1766619867e-8*cos(2.000000000*t)-.4774648292*sin(2.000000000*t)-.7998872189e-9*cos(3.000000000*t)+.1750704373e-...
fs[5](t) := 1.000000000+.4774648292e-9*cos(.9999999999*t)-.9549296583*sin(.9999999999*t)+.1766619867e-8*cos(2.000000000*t)-.4774648292*sin(2.000000000*t)-.7998872189e-9*cos(3.000000000*t)+.1750704373e-...
fs[5](t) := 1.000000000+.4774648292e-9*cos(.9999999999*t)-.9549296583*sin(.9999999999*t)+.1766619867e-8*cos(2.000000000*t)-.4774648292*sin(2.000000000*t)-.7998872189e-9*cos(3.000000000*t)+.1750704373e-...

>    fpe:=proc(x) local y;y:=x; while y < A do y:=y+2*p;od; while y > B do y:=y-2*p;od;evalf(subs(t=y,f(t)));end;

fpe := proc (x) local y; y := x;  while y < A do y := y+2*p end do;  while B < y do y := y-2*p end do; evalf(subs(t = y,f(t))) end proc

>    fpe(2);

0.

>    Pf:=plot(fpe,pleft..pright,numpoints=200):Pfs:=plot(fs[N](t),t=pleft..pright,color=blue,numpoints=500):

>    display(Pf,Pfs);

[Maple Plot]

>   

>   

>   

>   

>