I am trying to compute the Fourier series for $f(x) = 0$ when $0 \lt x \leq \frac{\pi}{2}$ and $1$ when $\frac{\pi}{2} \lt x \leq \pi$.
I've gotten $a_o = \frac{1}{2}$ which I hope is right.
I'm trying to calculate $a_n$ and $b_n$ but I'm not sure how to compute the integrals.
I got $a_n = \frac{1}{\pi}\int_{0}^{\pi} f(x)\cos(nx)dx$
$a_n = \frac{\sin(\pi n)-\sin(\frac{\pi n}{2})}{\pi n}$
$b_n = \frac{1}{\pi}\int_{0}^{\pi} f(x)\sin(nx)dx$
$b_n = \frac{-\cos(\pi n) + \cos(\frac{\pi n}{2})}{\pi n}$
I'm not sure how to move from here or if these are even on the right track.
We extend the function f on $[-\pi,\pi]$ by defining $f(-x)=f(x)\,\,$. Using the standard formula for a Fourier series and noticing that
$b_{n}=0$ for all $n$ we get:
$f(x)=\frac{1}{2}+2\sum_{k=0}^{+\infty }\frac{(-1)^{k+1}}{(2k+1)\pi }cos(2k+1)x$
forgive me for any miscalculations!