# Fourier-Series of a part-wise defined function?

I have a function f given as

$$f(x) = \begin{cases} ax&\text{ if }\quad-\pi \leq x \leq 0\\ bx&\text{ if }\quad 0<x\leq\pi \end{cases}$$ I am supposed to develop the fourier series of this function, using the scalar product $$\varphi(f,g) = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x)g(x)dx$$ and $$a_n=\varphi(f,\cos(n x))\\ b_n=\varphi(f,\sin(n x))\\ f(x) = \frac{a_0}{2} +\sum\limits_{n=1}^{\infty} a_n\cos(nx)+b_n\sin(nx)$$

I came up with $$f(x)=\sum\limits_{n=1}^{\infty} \frac{-2a \cos(n\pi)}{n}\sin(nx)$$ for the first case and $$f(x) = \sum\limits_{n=1}^{\infty} \frac{-2b \cos(n\pi)}{n}\sin(nx)$$ for the other one - but that's two fourier series, not one, so I'm sure this is wrong. That being said, I have no idea how else I would go about this. Especially troubling is that the task demands that I calculate $$\sum\limits_{n=0}^{\infty} \frac{1}{(2n+2)^2}$$ somehow by setting $x$ to $0$ - but my series is $0$ at $x=0$ (and at least that seems to be right, because the function is too).

So if anyone could clear me up on how to solve this tasks and what misunderstandings I'm sure I've made, that would be great.

-

while calculating the Fourier coefficients you have to use the definition of the function (not only one of its parts). You calculated the series for $f_1(x) = ax$ and $f_2(x) = bx$ but not for your $f$. So for example \begin{align*} a_0 &= \frac 1\pi\int_{-\pi}^\pi f(x)\, dx\\\ &= \frac 1\pi\left(\int_{-\pi}^0 ax\, dx + \int_0^\pi bx\, dx\right)\\\ &= \frac 1\pi\left( -\frac{a\pi^2}2 + \frac{b\pi^2}2 \right)\\\ &= \pi \cdot \frac{b-a}2 \end{align*} I think yoou can do the other coefficients now for yourself.