# Fourier sine series simplification

I'm having trouble simplifying a Fourier sine expansion for the following function: $$f(x) = \max\{{\frac{\pi}{2}, x}\}$$ on the interval of $$[0,\pi]$$. Since we're doing a sine series then $$a_n = 0$$ and the function collapses down to $$f(x) = \sum_{n=1}^{\infty}b_n\sin(nx)$$, where $$b_n = \frac{2}{\pi}\int_{0}^{\pi}f(x)\sin(nx)dx = \frac{2}{\pi}\bigg(\int_{0}^{\pi/2}\frac{\pi}{2}\sin(nx) dx \quad+ \quad\int_{\pi/2}^{\pi}x\sin(nx)dx)\bigg)$$ which I've managed to calculate (hopefully correctly) as: $$b_n = \frac{2}{\pi}\bigg(\frac{\pi}{2n} - \frac{\pi}{n}\cdot(-1)^n - \frac{1}{n^2}\sin\big(\frac{n\pi}{2}\big) \bigg)$$

Now I'm kinda stuck. I mean I could just put this into the final formula but I think there is a way to simplify it, just can't quite find it. The problematic part is obviously $$\sin\big(\frac{n\pi}{2}\big)$$ since for $$n = 2k$$ it is equal to zero. But if $$n$$ is an odd number it's either $$-1$$ or $$1$$. I've tried to get rid of the even elements in the sum (I had hoped they would be zero), but: $$b_{2n}= \frac{2}{\pi}\bigg(\frac{\pi}{4n} - \frac{\pi}{2n}\cdot(-1)^{2n}-\frac{1}{(2n)^2}\sin\big(n\pi\big)\bigg) = \frac{2}{\pi}\bigg(\frac{\pi}{4n} - \frac{\pi}{2n}\bigg) = \frac{2}{\pi}\cdot\bigg(-\frac{\pi}{4n}\bigg) = -\frac{1}{2n}$$

Looks pretty neat but still doesn't help me all that much. Any ideas on how to simplify this?

Thanks.

So you know that $$\sin\left(\dfrac{n\pi}{2}\right)$$ is $$0$$ if $$n$$ is even, and $$-1$$ or $$1$$ if $$n$$ is odd. So why not separate cases even furthur: If$$n=2k+1$$, $$k$$ can be even or odd, so you have $$n=4k+1$$ or $$n=4k+3$$. So do the sum like this:
$$f(x)=\sum_{n=1}^\infty b_{2n}\sin(2nx)+\sum_{n=1}^\infty b_{4n+1}\sin((4n+1)x)+\sum_{n=1}^\infty b_{4n+3}\sin((4n+3)x).$$