f[x_] := x^2

*In[2]:=*

a[0] := (1/(2*Pi)) Integrate[f[x], {x,-Pi,Pi}]

*In[3]:=*

a[0]

*Out[3]=*

2 Pi --- 3

This is the value of the constant term, a0.

*In[4]:=*

TrigId = {Cos[Pi n_] -> (-1)^n, Sin[Pi n_] -> 0}

*Out[4]=*

n {Cos[Pi (n_)] -> (-1) , Sin[Pi (n_)] -> 0}

*In[5]:=*

a[m_] := (2/(2*Pi)) Integrate[f[x]*Cos[2 m Pi x/(2*Pi)], {x,-Pi,Pi}]

*In[6]:=*

a[m] /. TrigId

*Out[6]=*

m 4 (-1) ------- 2 m

These are the coefficients am--the coefficients of the Cosine terms.

*In[7]:=*

b[n_] := (2/(2*Pi)) Integrate[f[x]*Sin[2 n Pi x/(2*Pi)], {x,-Pi,Pi}]

*In[8]:=*

b[n]

*Out[8]=*

0

These coefficients are all zero because x^2 is even and Sin(x) is odd.

*In[9]:=*

Clear[FullSeries]

Here is the F Series for x^2 on [-Pi,Pi].

*In[10]:=*

FullSeries[x_,N_] := (Pi^2/3) + \ Sum[((4*(-1)^m)/(m^2))Cos[2 Pi m x/(2*Pi)],{m,1,N}]

*In[11]:=*

Plot[{FullSeries[x,1], f[x]}, {x,-Pi, Pi}]

*Out[12]=*

-Graphics-

*In[13]:=*

Plot[{FullSeries[x,3], f[x]}, {x,-Pi, Pi}]

*Out[14]=*

-Graphics-

*In[15]:=*

Plot[{FullSeries[x,10], f[x]}, {x,-Pi, Pi}]

*Out[16]=*

-Graphics-

Now, let's find the Fourier Series for x^3 over the interval [-Pi, Pi].

*In[17]:=*

f[x_] := x^3

*In[18]:=*

a[0] := (1/(2*Pi)) Integrate[f[x], {x,-Pi,Pi}]

*In[19]:=*

a[0]

*Out[19]=*

0

The constant term a0 is 0 because 1 is even and x^3 is odd.

*In[20]:=*

a[m_] := (2/(2*Pi)) Integrate[f[x]*Cos[2 m Pi x/(2*Pi)], {x,-Pi,Pi}]

*In[21]:=*

a[m]

*Out[21]=*

0

All of the Cosine terms are zero because Cosine(x) is even and x^3 is odd.

*In[22]:=*

b[n_] := (2/(2*Pi)) Integrate[f[x]*Sin[2 n Pi x/(2*Pi)], {x,-Pi,Pi}]

*In[23]:=*

b[n] /. TrigId

*Out[23]=*

n n 3 3 n n 3 3 6 (-1) n Pi - (-1) n Pi -6 (-1) n Pi + (-1) n Pi --------------------------- - ---------------------------- 4 4 n n ---------------------------------------------------------- Pi

*In[24]:=*

Simplify[%]

*Out[24]=*

n 2 2 2 (-1) (6 - n Pi ) -------------------- 3 n

The full F series will consist entirely of Sine terms with the coefficients bn as above.

*In[25]:=*

Clear[FullSeries]

Here is the F Series for x^3 on [-Pi,Pi].

*In[26]:=*

FullSeries[x_,N_] := Sum[((2(-1)^n)(6-n^2*Pi^2)/(n^3))Sin[2 Pi n x/(2*Pi)],{n,1,N}]

*In[27]:=*

Plot[{FullSeries[x,1], f[x]}, {x,-Pi, Pi}]

*Out[28]=*

-Graphics-

*In[29]:=*

Plot[{FullSeries[x,3], f[x]}, {x,-Pi, Pi}]

*Out[30]=*

-Graphics-

*In[31]:=*

Plot[{FullSeries[x,10], f[x]}, {x,-Pi, Pi}]

*Out[32]=*

-Graphics-

Now, let's find the Fourier Series for x^4 over the interval [-Pi, Pi].

*In[33]:=*

f[x_] := x^4

*In[34]:=*

a[0] := (1/(2*Pi)) Integrate[f[x], {x,-Pi,Pi}]

*In[35]:=*

a[0]

*Out[35]=*

4 Pi --- 5

This is the value of the constant term, a0.

*In[36]:=*

a[m_] := (2/(2*Pi)) Integrate[f[x]*Cos[2 m Pi x/(2*Pi)], {x,-Pi,Pi}]

*In[37]:=*

Simplify[a[m] /. TrigId]

*Out[37]=*

m 2 2 8 (-1) (-6 + m Pi ) --------------------- 4 m

These are the coefficients am--the coefficients of the Cosine terms.

*In[38]:=*

b[n_] := (2/(2*Pi)) Integrate[f[x]*Sin[2 n Pi x/(2*Pi)], {x,-Pi,Pi}]

*In[39]:=*

b[n]

*Out[39]=*

0

These coefficients are all zero because x^4 is even and Sin(x) is odd.

*In[40]:=*

Clear[FullSeries]

Here is the F Series for x^4 on [-Pi,Pi].

*In[41]:=*

FullSeries[x_,N_] := (Pi^4/5) + \ Sum[((8*(-1)^m)(-6+m^2 Pi^2)/(m^4))Cos[2 Pi m x/(2*Pi)],{m,1,N}]

Up to Solution to Problem IV.5