f(x)=x

Let's look at f(x)=x. Remember, the functions must be periodic with period 2Pi, so what we really consider is its periodic extension f^(x)=x from -Pi to Pi, x-2Pi from Pi to 3Pi, etc., which is discontinuous at x=Pi, 3Pi, etc. Remember, f^ is defined as its average value at the jumps.

In[51]:=

  Clear[part1,part2,part3,part4]
  part1=Plot[x+2Pi,{x,-3Pi,-Pi},DisplayFunction->Identity];
  part2=Plot[x,{x,-Pi,Pi},DisplayFunction->Identity];
  part3=Plot[x-2Pi,{x,Pi,3Pi},DisplayFunction->Identity];
  part4=ListPlot[{{-3Pi,0},{-Pi,0},{Pi,0},{3Pi,0}}
  ,PlotStyle->{RGBColor[1,0,0]},DisplayFunction->Identity];
  graphoff=Show[part1,part2,part3,part4,
  DisplayFunction->$DisplayFunction,
  AspectRatio->Automatic,Ticks->{{-3Pi,-Pi,Pi,3Pi},Automatic}];

Let's find the Fourier coefficients.

In[52]:=

  Clear[a0,a,b,Sn]
  a0=(1/2Pi) Integrate[x,{x,-Pi,Pi}];
  a=(1/Pi)Table[innerproduct[x,u[x][[i]],x],{i,1,10}];
  b=(1/Pi)Table[innerproduct[x,v[x][[i]],x],{i,1,10}];

In[53]:=

  a0
  a

Out[53]=

  0

Out[54]=

  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Well?

Well? ...

In[55]:=

  b

Out[55]=

          2    1   2    1   2    1   2    1
  {2, -1, -, -(-), -, -(-), -, -(-), -, -(-)}
          3    2   5    3   7    4   9    5

Can you see the pattern?

Can you see the pattern? ...

Let's calculate a few partial sums.

In[56]:=

  Sn=Table[Sum[b[[k]]Sin[k x],{k,1,n}],{n,1,10}];

Let's see how we did.

In[57]:=

  sn1=Plot[Sn[[1]],{x,-2 Pi,2 Pi},DisplayFunction->Identity];
  Show[graphoff,sn1,DisplayFunction->$DisplayFunction,
  PlotLabel->FontForm["b1Sin[x]",{"Helvetica-Bold",12}]];

In[58]:=

  sn3=Plot[Sn[[3]],{x,-2 Pi,2 Pi},DisplayFunction->Identity]
  Show[graphoff,sn3,PlotLabel->
  FontForm["b1Sin[x]+b2Sin[2x]+b3Sin[3x]",{"Helvetica-Bold",12}]];

Out[58]=

  -Graphics-

In[59]:=

  sn5=Plot[Sn[[5]],{x,-2 Pi,2 Pi},DisplayFunction->Identity]
  Show[graphoff,sn5, PlotLabel->
  FontForm["Sum(k=1 to 5) bkSin[kx]",{"Helvetica-Bold",12}]];

Out[59]=

  -Graphics-

In[60]:=

  sn10=Plot[Sn[[10]],{x,-2 Pi,2 Pi},DisplayFunction->Identity]
  Show[graphoff,sn10, PlotLabel->
  FontForm["Sum(k=1 to 10) bkSin[kx]",{"Helvetica-Bold",12}]];

Out[60]=

  -Graphics-

Notice the Gibbs Phenomenon , as described in many textbooks.

Let's also investigate what happens at the points of discontinuity. For this function they are x= . . . -3Pi, -Pi, Pi, 3Pi, . . .

In[61]:=

  Sn/.x->Pi
  Sn/.x->-Pi
  Sn/.x->3 Pi

Out[61]=

  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Out[62]=

  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

Out[63]=

  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

The Fourier series is picking up the points from the periodic extension!

What is happening here is an illustration of a more general theorem.
Note: With the ideas of one sided limits described before we can define left and right handed derivatives by taking left and right handed limits of the difference quotient.

A Fourier Convergence Theorem:
If f is periodic with period 2T, and is piecewise continuous on [-T, T], (that is, discontinuous at only finitely many points) then the Fourier series of f converges to the mean value
1/2 [f(x0+) + f(x0-)] at each point at which left and right hand derivatives of f both exist.

Let's take note of a few things.
A. If f is continous at x0, the mean value of the left and right hand limits is just f(x0), since f(x0-)=f(x0+)=f(x0). So,
Under the stated hypotheses, the Fourier series of f(x) converges to f(x) everywhere that f(x) is continuous.

If f(x) has a jump discontinuity, then
Under the stated hypotheses, the Fourier series of f(x) converges to the average value at the jump everywhere f(x) has a jump discontinuity.

In terms of some of our new terminology, this theorem really says that
the Fourier series of f(x) converges to the periodic extension of f(x).

Just for completeness, this theorem is only a sufficient condition for the stated convergence; that is, you may have the stated convergence even if f does not meet the hypotheses.

Up to Fourier Series Examples