Fourier series for $$ f(x) = \begin{cases} 1 + x \quad&\text{ for }\quad {-1}<x<0\\ 1 \quad&\text{ for }\quad 0<x<1 \end{cases} $$
Have tried working this through and seem to get a different solution each time. Found an online calculator to aid, but resolves for different $a_n$, $b_n$ values than I get.
Totally lost and not sure where I'm going wrong :(
$a_n = \frac{2}{P}\int_{P} s(x)\cdot \cos\left(2\pi x \tfrac{n}{P}\right)\, dx$
$b_n = \frac{2}{P}\int_{P} s(x)\cdot \sin\left(2\pi x \tfrac{n}{P}\right)\, dx$.
$a_n= \int_{-1}^{0}((1+x).cos(\pi x n))dx + \int_{0}^{1}cos(\pi x n)dx$
$= 1+(\frac{1}{\pi n})^2 + \frac{2}{\pi n}sin(n \pi)+ (\frac{1}{\pi n})^2 cos(n \pi)= \frac{1+(-1)^n}{(n \pi)^2}+\frac{\pi n+2sin(\pi n)}{(n \pi)}$
Use $b_n$ expression to find it similarly.