Fourier Analysis - Series Convergence

Miller - Math 389 - Fall 2014

Mathematica had some trouble doing things with general functions as inputs. As I know there are simple closed form expressions for the Fourier coefficients, I just computed a few of them by hand to determine the pattern, and then used that.

Analysis for step function

(* definition of general functions need for expansions *)
e[n_,x_] := Exp[2 Pi I n x];
s[n_, x_] := Sin[2 Pi n x];
c[n_, x_] := Cos[2 Pi n x];
fweight[n_,NN_] := 1 - (n/NN);

(*fcoeff[fun_, n_] := Integrate[fun e[n,-x], {x,0,1}]
fccoeff[fun_, n_] := Integrate[fun c[n,x], {x,0,1}]*)
step[x_] := If[x < 0, -1, 1];
stepcoeff[n_] := Integrate[step[x] e[n,x], {x,-1/2,1/2}]
stepcoeff[0]
stepcoeff[13]
stepcoeff[-13]
stepcoeff[14]
(* thus coeff is 2i/nPi if n odd, 0 otherwise *)

(* Fejer series and Dirichlet series *)
fseries[x_,NN_] := Sum[fweight[n,NN] If[Mod[n,2] ==1,(-4./(n Pi)),0]Sin[2 Pi n x], {n,0,NN}];
dseries[x_, NN_]:=  Sum[  If[Mod[n,2] ==1,(-4./(n Pi)),0]Sin[2 Pi n x], {n,0,NN}]

(* This allows us to increase the number of terms, and we can see the convergence *)
Manipulate[Plot[fseries[1.0x,Floor[NNN]],{x,-1/2,1/2}], {NNN,1,50}]

(* Notice the Gibbs overshoot just before and after the discontinuity *)
Manipulate[Plot[dseries[1.0x,Floor[NNN]],{x,-1/2,1/2}],{NNN,1,50}]

Analysis for abs value function

The analysis is similar to the previous. Note that our function is NOT differentiable at the origin.

e[n_,x_] := Exp[2 Pi I n x];
s[n_, x_] := Sin[2 Pi n x];
c[n_, x_] := Cos[2 Pi n x];
fweight[n_,NN_] := 1 - (n/NN);
abs[x_] := Abs[x] - 1/4;
abscoeff[n_] := Integrate[abs[x] e[n,x], {x,-1/2,1/2}]
abscoeff[0]
abscoeff[13]
abscoeff[-13]
abscoeff[14]
(* so fourier coeff 0 if n even and 1/(n pi)^2 if n odd *)

abs[x_] := Abs[x]-1/4
abscoeff[n_] := Integrate[abs[x] e[n,x], {x,-1/2,1/2}]
abscoeff[0]
abscoeff[13]
abscoeff[-13]
abscoeff[14]
abscoeff[15]
abscoeff[16]
(* thus coeffs are 0 n even *)
(* for n odd it is -1/(n pi)^2 *)

(* Fejer series and Dirichlet series *)
absfseries[x_,NN_] := Sum[fweight[n,NN] If[Mod[n,2] ==1 ,(-2./(n Pi)^2),0]Cos[2 Pi n x], {n,0,NN}];
absdseries[x_, NN_]:=  Sum[  If[Mod[n,2] ==1,(-2./(n Pi)^2),0]Cos[2 Pi n x], {n,0,NN}]

Manipulate[Plot[absfseries[1.0x,Floor[NNN]],{x,-1/2,1/2}], {NNN,1,15}]

Manipulate[Plot[absdseries[1.0x,Floor[NNN]],{x,-1/2,1/2}],{NNN,1,15}]