I tried the following to create the Fourier-series of the function:
$$ f(x) = \begin{cases} x & 0<x<\pi \\ 0 & \pi < x < 2 \pi \end{cases}$$
This is what I tried:
$$a_0 = \frac{1}{\pi}\int\limits_0^\pi x dx = \frac{1}{\pi}\cdot\left(\frac{x^2}{2}|_0^\pi\right) = \frac{1}{\pi}\cdot\frac{\pi^2}{2} = \frac{\pi^2}{2\cdot\pi} = \frac{\pi}{2}$$
Is that right?
$$a_n = \frac{1}{\pi}\int\limits_0^\pi x \cdot \cos(nx) dx = \frac{1}{\pi}\cdot\left(\frac{x \cdot \sin(nx)}{n} + \frac{\cos(nx)}{n^2}\right)|_0^\pi$$
Assuming that $\sin(nx)$ is always $0$ and $\cos(nx)$ is $(-1)^n$. Is that ok??
$$ = \frac{1}{\pi}\cdot\left(\frac{0}{n} + \frac{(-1)^n}{n^2}\right) = \frac{1}{\pi}\cdot\left(\frac{(-1)^n}{n^2}\right) = \frac{(-1)^n}{\pi n^2}$$
That's already wrong I'm sure!
$$b_n = \frac{1}{\pi}\int\limits_0^\pi x \sin(nx) dx = \frac{1}{\pi}\cdot\left(\frac{x \cdot \cos(nx)}{n} + \frac{\sin(nx)}{n^2}\right)|_0^\pi$$
Assuming that $\sin(nx)$ is always $0$ and $\cos(nx)$ is $(-1)^n$. Is that ok??
$$ = \frac{1}{\pi}\cdot\left(\frac{\pi \cdot (-1)^n}{n}\right) = \frac{\pi\cdot(-1)^n}{\pi n} = \frac{(-1)^n}{n}$$ voila, thats wrong again :-)
A solution would be great, but I also need to understand what was my mistake.
Thank you in advance!
Plugging in $x=0$ and $x=\pi$ in $\sin (nx)$ indeed gives you $0$.
Plugging in $x=\pi$ in $\cos (nx)$ indeed gives you $(-1)^n$.
But don't forget that plugging in $x=0$ in $\cos (nx)$ gives you $1$.
Also, in the integral for $b_n$, there seems to be a minus sign missing after the integration by parts. Recheck your calculation.