You are on page 1of 11

Problem Set 08

Fourier Series
From equation 5 in Chapter 11.2, the Fourier Series is given by

n n
f HxL = a0 + Kan cos K xO + bn sin K xO
n=1
L L

The associate Fourier coefficients are given by the Euler formulas


1 L
a0 = f HxL x
2 L -L
1 L n
an = f HxL cos K xO x
L -L L
1 L n
bn = f HxL sin K xO x
L -L L
We can define these functions for our use.
I will call the Fourier series fs
In[1]:= fs@f_, indVar_, L_, nMax_D :=
nMax n
a0@f, indVar, LD + an@f, indVar, L, nD CosB indVarF +
n=1
L
nMax n
bn@f, indVar, L, nD SinB indVarF
n=1
L

The Euler formulas are given as follows


1 L
In[2]:= a0@f_, indVar_, L_D := f indVar
2L -L

1 L n
In[3]:= an@f_, indVar_, L_, n_D := f CosB indVarF indVar
L -L L
1 L n
In[4]:= bn@f_, indVar_, L_, n_D := f SinB indVarF indVar
L -L L

Half-Range Expansions
Half-Range Expansions can be easily represented.
2 ProblemSet08Soln.nb

Fourier Cosine Series


In[5]:= cosineSeries@func_, x_, L_, nLim_D :=
nLim n
a0hs@func, x, LD + anhs@func, x, L, nD CosB xF
n=1
L

Fourier Sine Series


In[6]:= sineSeries@func_, x_, L_, nLim_D :=
nLim n
bnhs@func, x, L, nD SinB xF
n=1
L

The limits of integration are slightly different in the half-series expansions, so we will account for that
here -
1 L
In[7]:= a0hs@f_, indVar_, L_D := f indVar
L 0

2 L n
In[8]:= anhs@f_, indVar_, L_, n_D := f CosB indVarF indVar
L 0 L
2 L n
In[9]:= bnhs@f_, indVar_, L_, n_D := f SinB indVarF indVar
L 0 L

Prob 11.1-14
In[10]:= f = x2
Out[10]= x2

In[11]:= solnProb14 =
fs@f, x , , 10D
2 4 1 4
Out[11]= - 4 Cos@xD + Cos@2 xD - Cos@3 xD + Cos@4 xD - Cos@5 xD +
3 9 4 25
1 4 1 4 1
Cos@6 xD - Cos@7 xD + Cos@8 xD - Cos@9 xD + Cos@10 xD
9 49 16 81 25
ProblemSet08Soln.nb 3

In[12]:= Plot@solnProb14, 8x, - , <D

Out[12]=
4

-3 -2 -1 1 2 3

Prob 11.1-15
Whereas the function is given by x 2 , the domain of interest ranges from 0 x 2 ,so we will have to
re-define the function by shifting it. The function under this domain looks like

In[13]:= f = x2 ;
In[14]:= Plot@f, 8x, 0, 2 <D
40

30

Out[14]= 20

10

1 2 3 4 5 6

Since we are told the above function has a period of 2, over the range from -2 to 2, it looks like
4 ProblemSet08Soln.nb

In[15]:= PlotAHx + 2 L2 HUnitStep@x - H- 2 LD - UnitStep@xDL +


x2 HUnitStep@xD - UnitStep@x - 2 DL, 8x, - 2 , 2 <E
40

30

Out[15]= 20

10

-6 -4 -2 2 4 6

So the new function I


m interested in is over the range of - to is
In[16]:= fnew =
Hx + 2 L2 HUnitStep@x - H- 2 LD - UnitStep@xDL + x2 HUnitStep@xD - UnitStep@x - 2 DL;

In[17]:= solnProb15 =
fs@fnew, x , , 10D
4 2 4 1 4
Out[17]= + 4 Cos@xD + Cos@2 xD + Cos@3 xD + Cos@4 xD + Cos@5 xD +
3 9 4 25
1 4 1 4 1
Cos@6 xD + Cos@7 xD + Cos@8 xD +Cos@10 xD -Cos@9 xD +
9 49 16 81 25
4 4
4 Sin@xD - 2 Sin@2 xD - Sin@3 xD - Sin@4 xD - Sin@5 xD -
3 5
2 4 1 4 2
Sin@6 xD - Sin@7 xD - Sin@8 xD - Sin@9 xD - Sin@10 xD
3 7 2 9 5

In[18]:= Plot@solnProb15, 8x, 0 , 2 <D


40

30

20
Out[18]=

10

1 2 3 4 5 6

Prob 11.1-20
ProblemSet08Soln.nb 5

Prob 11.1-20

In[19]:= f=- + x UnitStepBx - - F - UnitStepBx - F + 1;
2 2 2

In[20]:= f = PiecewiseB::- ,x<- >,
2 2

:x, - <x< >,
2 2

: , x > >>, 8x, - , <F
2 2

-2 x<-2

x -2 <x< 2
Out[20]=

2
x> 2
8x, - , < True

In[21]:= Plot@f, 8x, - , <D

1.5

1.0

0.5

Out[21]=
-3 -2 -1 1 2 3

-0.5

-1.0

-1.5

In[22]:= solnProb16 =
fs@f, x , , 10D
H2 + L Sin@xD 1 H- 2 + 3 L Sin@3 xD 1 H2 + 5 L Sin@5 xD
Out[22]= - Sin@2 xD + - Sin@4 xD + -
2 9 4 25
1 H- 2 + 7 L Sin@7 xD 1 H2 + 9 L Sin@9 xD 1
Sin@6 xD + - Sin@8 xD + - Sin@10 xD
6 49 8 81 10
6 ProblemSet08Soln.nb

In[23]:= Plot@solnProb15, 8x, - , <D


40

30

20
Out[23]=

10

-3 -2 -1 1 2 3

Prob 11.2-12
Since the f[x] and f[-x] are the same, this is an even function.

H- xL2
In[24]:= 1-
4
2
x
Out[24]= 1-
4

First, we define the function


In[25]:= f=
x2
1-
4
x2
Out[25]= 1-
4

and we can check out the plot


ProblemSet08Soln.nb 7

In[26]:= Plot@f, 8x, - 2, 2<D


1.0

0.8

0.6

Out[26]=

0.4

0.2

-2 -1 1 2

1.0

0.8

0.6

0.4

0.2

-2 -1 1 2

Determining the Fourier series out for the first 5 terms gives
In[27]:= fs@f, x, 2, 5D
x 3x 5x
2 4 CosA E Cos@ xD 4 CosB 2
F Cos@2 xD 4 CosA E
2 2
Out[27]= + - + - +
3 2 2 9 2 4 2 25 2

Prob 11.2-23
First, we define the function
In[28]:= f=1
Out[28]= 1

and we can check out the plot


8 ProblemSet08Soln.nb

In[29]:= Plot@f, 8x, 0, 4<D


2.0

1.5

Out[29]= 1.0

0.5

1 2 3 4

In this case, L is clearly equal to 4.

Part (a)
The Fourier cosine series is
In[30]:= cosineSeries@f, x, 4, 5D
Out[30]= 1

Part (b)
The Fourier sine series is
In[31]:= sineSeries@f, x, 4, 5D
x 3x 5x
4 SinA E 4 SinB 4
F 4 SinA E
4 4
Out[31]= + +
3 5

Supplemental Problem 8.1


Fourier code is at the beginning of this Mathematica notebook.
To solve Problem 24,
In[32]:= f = Piecewise@
880, x < 2<,
81, x > 2<<, 8x, 0, 4<D
0 x<2
Out[32]= 1 x>2
8x, 0, 4< True
ProblemSet08Soln.nb 9

In[33]:= soln3term =
sineSeries@f, x, 4, 3D
x x 3x
2 SinA E 2 SinA E 2 SinB 4
F
4 2
Out[33]= - +
3

In[34]:= soln5term =
sineSeries@f, x, 4, 5D
x x 3x 5x
2 SinA E 2 SinA E 2 SinB 4
F 2 SinA E
4 2 4
Out[34]= - + +
3 5

In[35]:= soln10term =
sineSeries@f, x, 4, 10D
x x 3x 5x
2 SinA E 2 SinA E 2 SinB 4
F 2 SinA E
4 2 4
Out[35]= - + + -
3 5
3x 7x 9x 5x
2 SinB 2
F 2 SinA E 2 SinB 4
F 2 SinA E
4 2
+ + -
3 7 9 5

In[36]:= soln100term =
sineSeries@f, x, 4, 100D;

Plots
In[37]:= fPlot =
Plot@f, 8x, 0, 4<, PlotStyle 8Red, Thick<D
1.0

0.8

0.6

Out[37]=

0.4

0.2

1 2 3 4
10 ProblemSet08Soln.nb

In[38]:= threeTermPlot =
Plot@soln3term, 8x, 0, 4<, PlotStyle GreenD
1.2

1.0

0.8

Out[38]= 0.6

0.4

0.2

1 2 3 4

In[39]:= fiveTermPlot =
Plot@soln5term, 8x, 0, 4<, PlotStyle PurpleD
1.2

1.0

0.8

0.6
Out[39]=

0.4

0.2

1 2 3 4

In[40]:= tenTermPlot =
Plot@soln10term, 8x, 0, 4<, PlotStyle OrangeD
1.2

1.0

0.8

0.6
Out[40]=

0.4

0.2

1 2 3 4
ProblemSet08Soln.nb 11

In[41]:= hundredTermPlot =
Plot@soln100term, 8x, 0, 4<D
1.2

1.0

0.8

0.6
Out[41]=

0.4

0.2

1 2 3 4

In[42]:= Show@fPlot, threeTermPlot, fiveTermPlot,


tenTermPlot, hundredTermPlot, PlotRange AllD
1.2

1.0

0.8

0.6
Out[42]=

0.4

0.2

1 2 3 4

You might also like