In[21]:=

Needs["Calculus`FourierTransform`"]

In[22]:=

Needs["Graphics`Colors`"]

Fourier Series

In this notebook we will see some examples of 2L-periodic extensions of functions. Mathematica can be used to plot them. If f(x) is the function you wish to extend, then plot f[Mod[x,2L,-L]].

Example 1

In[23]:=

f[x_] := x

In[24]:=

fbar[x_] := f[Mod[x, 2, -1]]

Here we plot the original function together with its 2-periodic extension.

In[25]:=

Plot[{f[x], fbar[x]}, {x, -3, 3}, PlotStyle→ {Black, Red}, AxesLabel→ {"x", "y"}]

[Graphics:HTMLFiles/index_6.gif]

Out[25]=

-Graphics -

Here is the 3-term Fourier series for f(x).

In[26]:=

fsf3 = FourierTrigSeries[f[x], x, 3, FourierParameters→ {1, 1/2}]

Out[26]=

1/2 ((4 Sin[π x])/π - (2 Sin[2 π x])/π + (4 Sin[3 π x])/(3 π))

In[27]:=

Plot[{fsf3, fbar[x]}, {x, -3, 3}, PlotStyle→ {Black, Red}, AxesLabel→ {"x", "y"}]

[Graphics:HTMLFiles/index_11.gif]

Out[27]=

-Graphics -

We can also plot the error in the truncated trigonometric series representation of f(x).

In[28]:=

Plot[Abs[fsf3 - fbar[x]], {x, -3, 3}, AxesLabel→ {"x", "error"}, PlotRange→All]

[Graphics:HTMLFiles/index_14.gif]

Out[28]=

-Graphics -

Here is the 10-term Fourier series for f(x).

In[29]:=

fsf10 = FourierTrigSeries[f[x], x, 10, FourierParameters→ {1, 1/2}]

Out[29]=

In[30]:=

Plot[{fsf10, fbar[x]}, {x, -3, 3}, PlotStyle→ {Black, Red}]

[Graphics:HTMLFiles/index_19.gif]

Out[30]=

-Graphics -

We should note that where the 2-periodic extension of f(x) has a discontinuity the Fourier Series converges to 0 which is the average of -1 and 1, the right and left hand limits respectively of the periodic extension.

We can again examine the error in the approximation.

In[31]:=

Plot[Abs[fsf10 - fbar[x]], {x, -3, 3}, AxesLabel→ {"x", "error"}, PlotRange→All]

[Graphics:HTMLFiles/index_22.gif]

Out[31]=

-Graphics -

Example 2

In[32]:=

f[x_] := UnitStep[x] x^2 (3 - x)

In[33]:=

fbar[x_] := f[Mod[x, 6, -3]]

In[34]:=

Plot[{f[x], fbar[x]}, {x, -12, 12}, PlotStyle→ {Black, Red}, PlotRange→ {-4, 4}]

[Graphics:HTMLFiles/index_27.gif]

Out[34]=

-Graphics -

Here is the 3-term Fourier series for f(x).

In[35]:=

fsf3 = FourierTrigSeries[f[x], x, 3, FourierParameters→ {1 - 2Log[3]/Log[6], 1/6}]//Simplify

Out[35]=

In[36]:=

Plot[{fsf3, fbar[x]}, {x, -12, 12}, PlotStyle→ {Black, Red}, PlotRange→All]

[Graphics:HTMLFiles/index_32.gif]

Out[36]=

-Graphics -

We can also plot the error in the truncated trigonometric series representation of f(x).

In[37]:=

Plot[Abs[fsf3 - fbar[x]], {x, -12, 12}, AxesLabel→ {"x", "error"}, PlotRange→All]

[Graphics:HTMLFiles/index_35.gif]

Out[37]=

-Graphics -

Here is the 10-term Fourier series for f(x).

In[38]:=

fsf10 = FourierTrigSeries[f[x], x, 10, FourierParameters→ {1 - 2Log[3]/Log[6], 1/6}]//Simplify

Out[38]=

In[39]:=

Plot[{fsf10, fbar[x]}, {x, -12, 12}, PlotStyle→ {Black, Red}, PlotRange→All]

[Graphics:HTMLFiles/index_40.gif]

Out[39]=

-Graphics -

We can again examine the error in the approximation.

In[40]:=

Plot[Abs[fsf10 - fbar[x]], {x, -12, 12}, AxesLabel→ {"x", "error"}, PlotRange→All]

[Graphics:HTMLFiles/index_43.gif]

Out[40]=

-Graphics -


Created by Mathematica  (February 15, 2006) Valid XHTML 1.1!