## Part b) Find the Fourier Series for the functions f(x)=x^2, x^3, and x^4 on the interval [0,1]

In[42]:=
`  f[x_] := x^2`

In[43]:=

`  a[0] := (1/1) Integrate[f[x], {x,0,1}]`

In[44]:=

`  a[0]`

Out[44]=

```  1
-
3
```

This is the value of the constant term, a0 (the average of the function).

In[45]:=

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

In[46]:=

`  a[m]`

Out[46]=

```                                        2   2
2 m Pi Cos[2 m Pi] - Sin[2 m Pi] + 2 m  Pi  Sin[2 m Pi]
-------------------------------------------------------
3   3
2 m  Pi
```

In[47]:=

`  % /. TrigId`

Out[47]=

```      2 m
(-1)
-------
2   2
m  Pi
```

I will introduce another simplifying function, goodId.

In[48]:=

`  goodId = {(-1)^(2*n_) -> 1}`

Out[48]=

```       2 (n_)
{(-1)       -> 1}
```

In[49]:=

`  a[m] /. TrigId /. goodId`

Out[49]=

```    1
------
2   2
m  Pi
```

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

In[50]:=

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

In[51]:=

`  Simplify[b[n] /. TrigId]  /. goodId`

Out[51]=

```     1
-(----)
n Pi
```

These are the coefficients bn for the Sine terms.

In[52]:=

`  Clear[FullSeries]`

Here is the F Series for x^2 on [0,1].

In[53]:=

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

In[54]:=

`  Plot[{FullSeries[x,2], f[x]}, {x,0,1}]`

Out[55]=

```  -Graphics-
```

In[56]:=

`  Plot[{FullSeries[x,8], f[x]}, {x,0,1}]`

Out[57]=

```  -Graphics-
```

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

In[58]:=

`  f[x_] := x^3`

In[59]:=

`  a[0] := (1/1) Integrate[f[x], {x,0,1}]`

In[60]:=

`  a[0]`

Out[60]=

```  1
-
4
```

This is the value of the constant term, a0.

In[61]:=

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

In[62]:=

`  Simplify[a[m]  /. TrigId  /. goodId]`

Out[62]=

```     3
--------
2   2
2 m  Pi
```

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

In[63]:=

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

In[64]:=

`  Simplify[b[n]  /. TrigId  /. goodId]`

Out[64]=

```         2   2
3 - 2 n  Pi
------------
3   3
2 n  Pi
```

These are the coefficients bn for the Sine terms.

In[65]:=

`  Clear[FullSeries]`

Here is the F Series for x^3 on [0,1].

In[66]:=

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

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

In[67]:=

`  f[x_] := x^4`

In[68]:=

`  a[0] := (1/1) Integrate[f[x], {x,0,1}]`

In[69]:=

`  a[0]`

Out[69]=

```  1
-
5
```

This is the value of the constant term, a0.

In[70]:=

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

In[71]:=

`  Simplify[a[m]  /. TrigId  /. goodId]`

Out[71]=

```          2   2
-3 + 2 m  Pi
-------------
4   4
m  Pi
```

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

In[72]:=

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

In[73]:=

`  Simplify[b[n]  /. TrigId  /. goodId]`

Out[73]=

```       2   2
3 - n  Pi
----------
3   3
n  Pi
```

These are the coefficients bn for the Sine terms.

In[74]:=

`  Clear[FullSeries]`

Here is the F Series for x^4 on [0,1].

In[75]:=

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