2 similar question about how to find the $a_n$s and $b_n$ of a Fourier series Find the terms $b_n,\ n\geq 1$ so that $$x-\frac{\pi}{2}=\sum_{n=1}^{\infty}b_n \sin nx$$ for all $x\in (0,\pi)$.
A similar one:
Find the term $a_n, \ n \geq 0$ so that $$x-\frac{\pi}{2}=\frac{a_0}{2}+\sum_{n=1}^{\infty}a_n \cos nx$$ for all $x\in (0,\pi)$.
Could any one give me just a hint because that I think it is rather an algebra problem once you get the trick.

How much do you know already?
A $\sin$ series of a function defined on the interval $(0,\pi)$ is the Fourier series of an odd function defined on $(-\pi,\pi)$. The $\cos$ series being the Fourier series of an even function.
If we suppose that we have the full Fourier series of a function $$f(x) = \frac{a_0}{2} + \sum_{n=1}^\infty a_n \cos nx + b_n \sin nx$$
and that certain convergence criteria hold on the series, we can multiply $f(x)$ by one of the trigonometric terms, $\cos kx$ for example, and integrate on the interval $(-\pi,\pi)$.
$$\int_{-\pi}^\pi f(x)\cos kx \, \mathbb{d}x = \frac12 \int_{-\pi}^\pi a_0\cos kx \, \mathbb{d}x + \sum_{n=1}^\infty \int_{-\pi}^\pi a_n \cos nx \cos kx \, \mathbb{d}x + \sum_{n=1}^\infty \int_{-\pi}^\pi a_n \sin nx \cos kx \, \mathbb{d}x$$
But since $$\int_{-\pi}^\pi \cos nx \cos kx \, \mathbb{d}x = 0 \qquad \forall n \ne k$$and$$\int_{-\pi}^\pi \sin nx \cos kx \, \mathbb{d}x = 0 \qquad \forall n,k$$
The RHS of the previous equation is just $$a_k\int_{-\pi}^\pi \cos^2 kx \, \mathbb{d}x = \pi a_n$$
So we get $$a_n = \frac{1}{\pi} \int_{-pi}^\pi f(x)\cos kx \, \mathbb{d}x$$
And when $f(x)$ is an even function on $(-\pi,\pi)$ (as it must be when the series is a cosine series, have all $b_n = 0$, we get $$\frac{2}{\pi} \int_{0}^\pi f(x)\cos kx \, \mathbb{d}x$$
Similar work gets the equivalent result for the $b_n$ in a sine series.
