$$F(x)=\left\{ \begin{array}{rl} ax,&0<x<\pi,\\ bx,&-\pi<x<0, \end{array} \right.$$
So, far i've got: $$a_0 = - \frac{b\pi}{2} + \frac{a\pi}{2}$$ $$bn = \frac{1}{\pi} \frac{(-1)^{n+1}}{n}(a+b)$$
Can someone help me get $a_n$? I did try, but I don't really think $0$ is the solution. Thank you.
$$F(x) = \frac{a-b}{2}\ |x| + \frac{a+b}{2} x$$ for $-\pi<x<\pi$. The first part is an even function that corresponds to the $a_n$'s.
Without looking at tables, the formula for $a_n$, $n> 0$ is
$$\begin{align*} a_n &= \frac2{2\pi}\int_{-\pi}^\pi\frac{a-b}{2}\ |x|\cos nx\ dx\\ &= \frac{a-b}{2\pi}\int_{-\pi}^\pi|x|\cos nx\ dx\\ &= \frac{a-b}{2\pi}\int_{-\pi}^0(-x)\cos nx\ dx + \frac{a-b}{2\pi}\int_{0}^\pi x\cos nx\ dx\\ &= \frac{a-b}{\pi}\int_{0}^\pi x\cos nx\ dx\\ &= \frac{a-b}{n\pi}\int_{0}^\pi x\ d\sin nx\\ &= \frac{a-b}{n\pi}\left\{\left[x\sin nx\right]_0^\pi-\int_{0}^\pi \sin nx\ dx\right\}\\ &= \frac{a-b}{n\pi}\left\{\left[x\sin nx\right]_0^\pi+\left[\frac{\cos nx}n\right]_0^\pi\right\}\\ &= \frac{a-b}{n\pi}\left(0+\frac{\cos n\pi}{n} - \frac 1n\right)\\ &= \frac{(a-b)(\cos n\pi-1)}{n^2\pi}\\ &= \frac{(a-b)((-1)^n-1)}{n^2\pi}\\ &=\begin{cases} -\dfrac{2(a-b)}{n^2\pi}&n\text{ is odd}\\ 0&n\text{ is even, }n\ne 0\end{cases} \end{align*}$$
Or it is possible to do the following integration directly, and I don't think it is different:
$$a_n = \frac{2}{2\pi}\int_{-\pi}^\pi F(x)\cos nx\ dx$$