calculate Dirichlet integral get two different answer When I calculate Dirichlet integral. $$\int_0^{+\infty}\frac{\sin x}{x}\text{d}x$$
this integral is converge. and Dirichlet Kernel:$$D_N(x)=\sum_{n=-N}^{N}e^{inx}=\frac{\sin\left(\left(N+\frac{1}{2}\right)x\right)}{\sin\left(\frac{x}{2}\right)}$$
because of converge, $$\int_0^{\infty}\frac{\sin x}{x}\text{d}x = \lim_{n\rightarrow +\infty}\int_0^{(2n+1)\pi}\frac{\sin x}{x}\text{d}x$$
let $x = \left(n+ \frac{1}{2}\right)t$. so $$\int_0^{(2n+1)\pi}\frac{\sin x}{x}\text{d}x = \int_0^{2\pi}\frac{\sin \left(n+\frac{1}{2}\right)t}{t}\text{d}t$$
and
$$\int_0^{2\pi}\frac{\sin\left(\left(N+\frac{1}{2}\right)x\right)}{\sin\left(\frac{x}{2}\right)} \text{d}x = 2\pi$$
and $$f(x) = \frac{1}{\sin\frac{x}{2}}- \frac{1}{\frac{x}{2}}$$ is integrable on $[0,2\pi]$
by Riemann-Lebesgue lemma, we have:
$$\lim_{N \rightarrow +\infty}\int_0^{2\pi}\sin\left(\left(N+\frac{1}{2}\right)x\right)\left[\frac{1}{\sin\frac{x}{2}}- \frac{1}{\frac{x}{2}}\right]\text{d}x = 0$$
so $$\int_0^{+\infty}\frac{\sin x}{x}\text{d}x = \pi$$ what's wrong ?
if I choose $$\int_0^{\infty}\frac{\sin x}{x}\text{d}x = \lim_{n \rightarrow +\infty}\int_0^{(n+\frac{1}{2})\pi}\frac{\sin x}{x} \text{d}x$$ i will get the right answer $$\int_0^{\infty}\frac{\sin x}{x}\text{d}x = \frac{\pi}{2}$$
Maybe $$\lim_{n\rightarrow +\infty}\int_0^{(2n+1)\pi}\frac{\sin x}{x}\text{d}x \not= \lim_{n\rightarrow +\infty}\int_0^{(n+1/2)\pi}\frac{\sin x}{x}\text{d}x$$?
But Heine Theorem say this will be equal. please help me ,thanks very much.
 A: It is not true that $\displaystyle \frac{1}{\sin(x/2)}-\frac1{x/2}$ is absolutely integrable on $\displaystyle x\in[0,2\pi]$ since as $\displaystyle x\to2\pi$, $\sin(x/2)\to0$.
So, while it is true (use the summation representation of the Dirichlet kernel and symmetry of the kernel around $\pi$) that
$$\begin{align}
\int_0^{2\pi}\frac{\sin\left(\left(N+\frac12\right)x\right)}{\sin(x/2)}\,dx&=2\int_0^{\pi}\frac{\sin\left(\left(N+\frac12\right)x\right)}{\sin(x/2)}\,dx\tag1\\\\
&=2\pi
\end{align}$$
it is not true that
$$\lim_{N\to\infty}\int_0^{2\pi} \sin\left(\left(N+\frac12\right)x\right)\left(\frac1{\sin(x/2)}-\frac1{x/2}\right)\,dx=0\tag2$$
In fact, the limit in $(2)$ is equal to $\pi$.


Instead, we begin with the equality
$$\int_0^{(N+1/2)\pi}\frac{\sin(x)}{x}\,dx=\int_0^\pi \frac{\sin((N+1/2)x)}{x}\,dx\tag3$$
Noting that $\frac1{\sin(x/2)}-\frac1{x/2}$ is absolutely integrable on $[0,\pi]$, the Riemann Lebesgue Theorem guarantees that
$$\lim_{N\to\infty}\int_0^{\pi} \sin\left(\left(N+\frac12\right)x\right)\left(\frac1{\sin(x/2)}-\frac1{x/2}\right)\,dx=0\tag4$$
Finally, using $(2)-(4)$, we can assert that
$$\int_0^\infty \frac{\sin(x)}{x}\,dx=\frac\pi2$$
And we are done!
