# Fourier series for piecewise function

let $-\pi \leq x\leq \pi$ and $$f(x)=\begin{cases}-x-\pi, & \text{ if} -\pi \leq x\leq -\pi/ 2\\ \;\;\;x, & \text{ if } -\pi/2 \leq x\leq \pi/2\\ -x+\pi, & \text{ if } \pi/2 \leq x\leq \pi\end{cases}$$

it's easy to see that $f$ is odd so $a_0=a_n=0$ and $b_k=2\int _0^{\pi}f(x)\sin(kx)$for all positive integers $n$.

To compute $b_k$ I use the following auxiliar computations: aux 1, aux2

and get $b_k=\frac{4}{k^2}\sin \left(\frac{k\pi}{2}\right)$.

So the fourier series should be $$\sum _{k=1}^{+\infty}\frac{4}{k^2}\sin \left(\frac{k\pi}{2}\right)\sin(kx)$$ but when I check for $x=\pi /2$ I get $\pi ^2/2$ instead of $\pi /2$. It also fails for $x=1$ which seems to yield $\pi$ (I did a finite sum for this one because wolfram alpha cant find the sum of the series). And for $x=\pi$ it gives $0$ instead of $\pi$. EDIT: I just realised it supposed to give $0$ instead of $\pi$, so there's nothing wrong at $x=\pi$. Second EDIT: I did a mistake in the input in wolfram alpha. I now updated the links

what am I doing wrong?

-
because of not enough reputation I can't post more than 2 links. can someone please fix? thanks – anonymous May 29 '13 at 14:18
Thanks, anonymous, for taking the time to format! – amWhy May 29 '13 at 14:31
This is just a triangular wave. – Ataraxia May 29 '13 at 14:31
@amWhy thank you for the help. – anonymous May 29 '13 at 14:35
@ZettaSuro is that supposed to help me somehow? can you elaborate? – anonymous May 29 '13 at 14:36