I have the following problem. Let $$ f(x) = \begin{cases} x & 0\leq x \leq \frac{\pi}{2}, \\ x-\pi & \frac{\pi}{2} \leq x \leq \pi \end{cases} $$ and let $h$ be the odd extension of $f$ to $[-, ]$. Find the Fourier series of $h$ on $[-,]$.
So I defined $h$ as $$ h(x) = \begin{cases} x+\pi & -\pi\leq x \leq \frac{-\pi}{2}, \\ x & \frac{-\pi}{2} \leq x \leq 0. \end{cases} $$
Now, it's an odd extension so $a_n$ is $0$ and $b_n$ is $$b_n = \frac{2}{\pi}\int_{-\pi}^{-\pi/2} x\sin(nx)\, \mathrm dx + \frac{2}{\pi}\int_{-\pi/2}^{0} x\sin(nx) \, \mathrm dx + 2\int_{-\pi}^{-\pi/2} \sin(nx) \, \mathrm dx.$$
Now I got this answer: $$b_n = \frac{-2\cos(\frac{n\pi}{2})}{n}$$ which is wrong as it should be $$b_n = \frac{4}{n^2\pi}\sin\left(\frac{n\pi}{2}\right).$$
My question is: (1) how did they get that answer and (2) why do we even bother to do odd extension when we can say "oh, I did an odd expansion... The function is even now..."?
The answer $$b_n = \frac{4}{n^2\pi}\sin\left(\frac{n\pi}{2}\right)$$ is for a different problem, namely $$ f(x) = \begin{cases} x & 0\leq x \leq \frac{\pi}{2}, \\ \pi-x & \frac{\pi}{2} \leq x \leq \pi , \end{cases} $$ a continuous sawtooth graph. Unlike this one, your function is discontinuous at $x=\pi/2$.
[A Fourier series with coefficients going to zero as fast as $1/n^2$ converges uniformly, so it must yield a continuous function.]