# Fourier series of piecewise function

Ok, so this is a pretty simple function. I tried to plot the Fourier Series vs the function to see if I did things correctly, but the curves are just not having the same form.

Consider the function $$g(t)=\begin{cases}\sin \omega t & \text{if } t \in \left[0,\pi/\omega\right],\\ 0 & \text{if } t \in ]\pi/\omega,2\pi/\omega].\end{cases}$$

I extend this function periodically. The period is $2\pi/\omega$.

The Fourier coefficients for a periodic function $f(x):]x_0 + nT,x_0+(n+1)T)]_{n\in\mathbb Z}\to \mathbb R$ are:

$$a_0 = \frac{2}{T}\int_{x_0}^{x_0+T}f(x)dx,\\ a_k = \frac{2}{T}\int_{x_0}^{x_0+T}f(x)\cos\frac{2\pi k x}{T}dx,\\b_k = \frac{2}{T}\int_{x_0}^{x_0+T}f(x)\sin\frac{2\pi k x}{T}dx.$$

Then I get: $$a_0 = \frac{2}{\pi},\\ a_k = \begin{cases}0 & \text{if }k=1, \\ \frac{\cos \pi k + 1}{\pi - \pi k^2} & \text{otherwise},\end{cases}\\ b_k = 0.$$

And this is the plot I get with 40 terms of the fourier series for $\omega = \pi$

## 1 Answer

You have made an error in computing $b_1$: $$b_1=\frac{\omega}{\pi}\int_0^{\pi/\omega}\sin(\omega\,t)\sin(\omega\,t)\,dt=\frac12.$$

• Thanks a lot!!!!! :D I need to do more exercises to get more experience and keep myself from making these mistakes. Jun 8, 2015 at 14:15