I'm trying to create a proof of the Leibniz series $\sum_{k=0}^{\infty} \frac{(-1)^k}{2k+1} = \frac{\pi}{4}$ using the Dirichlet Kernel.
What I did is start with the kernel $$1+2 \left ( 1+\cos\theta + \cos 2\theta + \dots + \cos n\theta \right ) = \dfrac{\sin \left (n + \frac{1}{2} \right )x}{\sin x/2}$$ and then integrate both sides over the domain $x \in \left [0,\dfrac{\pi}{2} \right ]$.
I eventually got to this result. $$\dfrac{\pi}{2}+2\left ( 1 - \dfrac{1}{3} + \dfrac{1}{5} - ... + \dfrac{\sin n\pi/2}{n}\right ) = \int_{0}^{\frac{\pi}{2}}\dfrac{\sin \left (n + \frac{1}{2} \right )x}{\sin x/2} = 2\int_{0}^{\frac{\pi}{4}}\frac{\sin(2x+1)}{\sin x}dx$$ Now, we know that $$\int \dfrac{\sin(2n+1)x}{\sin x}=I_{n-1}-\int 2 \cos (2nx)dx$$ so $$I_n=\int_{0}^{\frac{\pi}{4}} \dfrac{\sin(2n+1)x}{\sin x}=I_{n-1}-\dfrac{1}{n} \sin \dfrac{n \pi}{2}$$ This is where I am unsure. In order to prove the Leibniz series, I need to somehow show that $$I_n=\int_{0}^{\frac{\pi}{2}}\dfrac{\sin \left (n + \frac{1}{2} \right )x}{\sin x/2} = \pi$$ However, by taking the limit as $n \rightarrow \infty$ from the right, it appears that $I_n$ is approaching $\dfrac{\pi}{4}$ as reducing the integral $I_n$ recursively yields $I_0 = \dfrac{\pi}{4}$ and all the other terms vanish.
What is going on here? I am not quite sure why things are not working out.
Let $D_n(x) = 1+2 \left ( \cos\theta + \cos 2\theta + \dots + \cos n\theta \right ) = \dfrac{\sin \left (n + \frac{1}{2} \right )x}{\sin x/2}$. I don't think it is useful to integrate $D_n$ recursively. Doing so produces the same Leibniz series $\sum \frac{1}{n} \sin \frac{n\pi }{2}$ on the right as you have on the left; so you'll end up proving that $0=0$.
How about this: $\int_0^{\pi} D_n(x) = \pi $ because all cosines integrate to $0$ over $[0,\pi]$. And for any fixed $a\in (0,\pi)$ (in particular, for $a=\pi/2$) we have $$\int_a^\pi D_n(x) \to 0 \quad \text{as }n\to\infty \tag{1}$$ To prove (1), you can either apply the Riemann-Lebesgue lemma, or do it from scratch: integrate by parts, turning $\sin(n+\frac12)x$ into $-(n+\frac12)^{-1}\cos(n+\frac12)x$, extract the valuable factor $(n+\frac12)^{-1}$, and estimate the integrand by a constant.
Conclusion: $\int_0^{\pi/2} D_n(x) \to \pi $ as $n\to\infty$. It is not actually equal to $\pi$; otherwise your integral identity would imply that $\pi$ is rational. :)