Leibniz formula using Fourier Series I have to show the Leibniz formula i.e $$\pi/4 = 1 - 1/3 + 1/5 - 1/7 + ...$$
and I have to do so using $f(x) = x/2$ on the interval $[0,2\pi]$ for this function being $2\pi$ periodic. 
It is clear that I have to use a Fourier series to reach the desired result. I have solved for both the Fourier sine and cosine series on the interval however I am unable to understand what to do after that. Should I try to further manipulate the series, if yes should it be sine or cosine series? Should I be looking at the convergence of the series at a certain point? Any help and hints are appreciated. 
The Sine series I'm getting is $$f(x) \sim \sum_{n=1}^\infty \frac 2n(-1)^{n+1}sin(\frac n2x)$$
 A: If f(x) is periodic with period $2\pi$ and f’(x) exists and is finite for $-\pi<x<\pi$ then f can be written as a Fourier series:
$$f(x)=\sum_{n=-\infty}^{\infty}a_{n}e^{inx}$$
where
$$a_{n}=\frac{1}{2\pi}\int_{-\pi}^{\pi}f(t)e^{-int}dt$$.
We shall also use the fact that
$$\int_{-\pi}^{\pi}e^{-int}dt=0$$
and
$$e^{-in\pi}=(e^{-i\pi})^{n}=(-1)^{n}=(e^{i\pi})^{n}=e^{in\pi}$$
Now let f(x) be periodic with period $2\pi$ where f(x) = x for $-\pi<x<\pi$ and f(-π)=f(π)=0.  Let us calculate $a_{n}$ for n≠0. The easiest way is to use partial integration:
$$a_{n}=\frac{1}{2\pi}\int_{-\pi}^{\pi}te^{-int}dt =\frac{(-1)^{n}}{2\pi in}(\pi-(-\pi))-\frac{(-1)^{n}}{2\pi in}\int_{-\pi}^{\pi}e^{-int}dt=\frac{(-1)^{n}}{in}-0$$
For n=0 we have
$$a_{0}=\frac{1}{2\pi}\int_{-\pi}^{\pi}tdt =\frac{1}{2\pi}\frac{1}{2}(\pi^{2}-(-\pi)^{2})=0$$
Since f(x) is differentiable at π/2, the Fourier series converges at that point, giving $$\frac{\pi}{2}=\sum_{n=-\infty}^{-1}\frac{(-1)^{n}}{in}e^{in\frac{\pi}{2}}+0+\sum_{n=1}^{\infty}\frac{(-1)^{n}}{in}e^{in\frac{\pi}{2}}$$ Changing n to –n in the first sum, we get $$\frac{\pi}{2}=\sum_{n=1}^{\infty}\frac{(-1)^{n}}{-in}e^{-in\frac{\pi}{2}}+\sum_{n=1}^{\infty}\frac{(-1)^{n}}{in}e^{in\frac{\pi}{2}}$$ Now $\frac{e^{inx}-e^{-inx}}{2i}=\sin(nx)$ and therefore $$\frac{\pi}{2}=2\sum_{n=1}^{\infty}\frac{(-1)^{n}}{n}\sin(\frac{n\pi}{2}).$$ Since $\sin(\frac{n\pi}{2})$ is 0 for all even multiples of $\pi/2$ and alternates between +1 and -1 for odd multiples, we have $$\frac{\pi}{4}=\sum_{n=1}^{\infty}\frac{(-1)^{n-1}}{2n-1}$$
