Fourier Half and Quarter Range Expansions
> | restart:N:=5:A:=0:B:=2:pleft:=-8:pright:=8:with(plots): |
Warning, the name changecoords has been redefined
Extensions of functions
> | f(t):=piecewise(t<A,0, t>A and t<B,4-t^2,t>B ,0);plot(f(t),t=-5..5); |
Even Extension of f:
> | ef:=proc(x) if x>=2*A-B and x < A then evalf(subs(t=2*A-x,f(t))) elif x>=A and x<=B then evalf(subs(t=x,f(t))) else 0 fi; end; |
> | ef(1);plot(ef,-5..5); |
Odd Extension of f:
> | of:=proc(x) if x>=2*A-B and x < A then evalf(subs(t=2*A-x,-f(t))) elif x>=A and x<=B then evalf(subs(t=x,f(t))) else 0 fi; end; |
> | plot(of,-10..10); |
> |
Periodic Extensions
> | Phalf:=B-A:Pquarter:=2*(B-A):P:=(B-A): |
> | fperiodic:=proc(x) local y;y:=x; while y < A do y:=y+P;od; while y > B do y:=y-P;od;evalf(subs(t=y,f(t)));end; |
> | fpeven:=proc(x) local y;y:=x; while y < 2*A-B do y:=y+2*Phalf;od; while y > B do y:=y-2*Phalf; od; ef(y);end; |
> | fpodd:=proc(x) local y;y:=x; while y < 2*A-B do y:=y+2*Phalf;od; while y > B do y:=y-2*Phalf; od; of(y);end; |
> | plot(fpeven,-20..10); |
> | plot(fpodd,-20..10); |
> | plot(fperiodic,-20..10); |
Half Range Expansions
> | p:=B-A:pp:=1/2*(B-A): |
> | a[0]:=2/p*int(f(t),t=A..B);aa[0]:=1/pp*int(f(t),t=A..B); |
> | aa[n]:=1/pp*int(f(t)*cos(n*Pi*t/pp),t=A..B); bb[n]:=1/pp*int(f(t)*sin(n*Pi*t/pp),t=A..B); |
> | a[n]:=2/p*int(f(t)*cos(n*Pi*t/p),t=A..B); b[n]:=2/p*int(f(t)*sin(n*Pi*t/p),t=A..B); |
> | fs[N](t):=1/2*aa[0]+sum(aa[n]*cos(n*Pi*t/pp)+bb[n]*sin(n*Pi*t/pp),n=1..N); |
> | fsine[N](t):=sum(b[n]*sin(n*Pi*t/p),n=1..N); |
> | fcosine[N](t):=1/2*a[0]+ sum(a[n]*cos(n*Pi*t/p),n=1..N); |
> | FSINE:=plot(fsine[N](t),t=pleft..pright,color=blue):FCOSINE:=plot(fcosine[N](t),t=pleft..pright,color=blue):F:=plot(fs[N](t),t=pleft..pright,color=blue): |
> | FEVEN:=plot(fpeven,pleft..pright,color=red):FPERIODIC:=plot(fperiodic,pleft..pright,color=red): |
> | ORIGINAL:=plot(f(t),t=pleft..pright,color=yellow,thickness=5,discont=true): |
> | FODD:=plot(fpodd,pleft..pright,color=red): |
> | display(FSINE,FODD,ORIGINAL); |
> |
> | display(FCOSINE,FEVEN,ORIGINAL); |
> | display(F,FPERIODIC,ORIGINAL); |
> |