Fourier series of function $f(x)=0$ if $0 < x \leq L/2$ and $f(x)=1$ if $L/2 < x \leq L$

1.9k Views Asked by At

I am attempting to work through a very simple problem.

Determine the Fourier series expansion for:

$$ f(x) = \begin{cases} 0 & 0 \leq x \leq L/2 \\ 1 & L/2 < x \leq L\end{cases}$$

I decide to use $\sin$ functions to produce the series.

$$f(x) = \sum_{n=1}^{\infty} a_n \sin(\frac{n\pi}{L} x)$$

By the orthogonality of sinusoids:

$$ a_n = \frac{2}{L}\int_{0}^{L} f(x) \sin(\frac{n\pi}{L} x)\;\textrm{d}x$$

So I determined $a_n$ as follows:

$$ \begin{align} a_n &= \frac{2}{L}\int_{0}^{L} f(x) \sin(\frac{n\pi}{L} x)\;\textrm{d}x \\ &= \frac{2}{L}\left[\int_{0}^{L/2} 0\;\textrm{d}x + \int_{L/2}^{L} \sin(\frac{n\pi}{L} x) \;\textrm{d}x\right] \\ &= \frac{2}{L}\int_{L/2}^{L} \sin(\frac{n\pi}{L} x) \;\textrm{d}x \\ &= -\frac{2}{n\pi}\cos(n\pi) \end{align} $$

Giving me a Fourier series expansion of the form:

$$f(x) = \sum_{n=1}^{\infty} -\frac{2}{n\pi}\cos(n\pi) \sin(\frac{n\pi}{L} x)$$

If I plot out the first few terms of this series though, I see the following: enter image description here

...which is nothing like $f(x)$. Can you explain what I am doing wrong? My guess is that there is something very fishy about the fact that I am losing information about half the function (between $0$ and $L/2$) just because the function is $0$ there. So, somehow, I should be considering a "shifted" Fourier series expansion?

1

There are 1 best solutions below

0
On BEST ANSWER

You made a mistake. $a_n$ should be

$$ a_n = -2\,{\frac {\cos \left( n\pi \right) -\cos \left( n\pi/2 \right) }{n\pi }}, $$

which gives the Fourier series

$$ f(x) = -2\sum_{n=1}^{\infty} {\frac {\cos \left( n\pi \right) -\cos \left( n\pi/2 \right) }{n\pi }} \sin\left( \frac{n\pi}{L}x \right). $$

Here is the plot of the first $80$ terms for $L=1$

enter image description here