# Fourier Sine Series of a Piecewise Smooth Odd Function

I am trying to find the Fourier sine series of the following function:

$$f\left(x\right)= \begin{cases} 1&x<L/2,\\ 0&x>L/2.\tag{1} \end{cases}$$

Let $L=1$. Then, this is what $\left(1\right)$ looks like:

I know that to find the Fourier sine series of $\left(1\right)$, I first need to find its odd extension $f_o$:

$$f_o\left(x\right)= \begin{cases} 1&0<x<L/2,\\ 0&L/2<x<L\text{ & }-L<x<L/2,\\ -1&-L/2<x<0.\tag{2} \end{cases}$$

Again, letting $L=1$, this is what $\left(2\right)$ looks like:

Finally, the Fourier sines series of a piecewise smooth, odd function $f\left(x\right)$ is given by

$$f\left(x\right)\sim\sum_{n=1}^{\infty}B_n\sin\frac{n\pi x}{L},$$

where

$$B_n=\frac{2}{L}\int_{0}^{L}f\left(x\right)\sin\frac{n\pi x}{L}.\tag{3}$$

Now, I am having a really hard time trying to find $\left(3\right)$ because, for the case where $0<x<L/2$, I get

$$\frac{2}{n\pi}\left(1-\cos\left(n\pi\right)\right),$$

and for the case where $-L/2<x<0$, I get

$$\frac{2}{n\pi}\left(\cos\left(n\pi\right)-1\right).$$

So, it is piecewise defined, but my book only gives one solution, that is,

$$\frac{2}{n\pi}\left(1-\cos\frac{n\pi}{2}\right).$$

What am I missing!?

$$B_n=\frac 2L \int_0^{L/2}\sin(\frac{n\pi}L x) dx$$ $$B_n=-\frac 2L \cos(\frac{n\pi}Lx)\frac{L}{n\pi}\bigg]_0^{L/2}$$ $$B_n=\frac{2}{n\pi}\left(1-\cos(\frac{n\pi}2)\right)$$
• Why did you integrate from $0$ to $L/2$ and not from $0$ to $L$? Oct 23, 2012 at 4:10
• I essentially did integrate from $0$ to $L$, but the function is zero from $L/2$ to $L$ so we can just ignore that part, since it will integrate to $0$ anyway. Oct 23, 2012 at 4:13
• Thank you. Aside from that question, I now know where I went wrong; I tried integrating from $-L$ to $L$! Oct 23, 2012 at 4:17