Pointwise limit of $f_N(x)=\frac{1}{N(x^2+1)}\cdot\sum_{n=1}^N\cos(nx)$ I want to show that the following pointwise limit holds:
$$\frac{\sum_{n=1}^N\cos(nx)}{N(x^2+1)}\to\begin{cases} 1, & x=0 \\ 0 & x\neq0 \end{cases}$$
The case $x=0$ is easy: we have, for any $\varepsilon>0$:
$$\frac{1}{N}\left\vert\sum_{n=1}^N\cos(nx)-N\right\vert=\left\vert\frac{N}{N}-1\right\vert=0<\varepsilon$$
for any $N$. However, I'm more troubled by the case where $x\neq0$. One issue is that we might have that $x$ is a multiple of $2\pi$, in which case we would have:
$$\frac{1}{N(x^2+1)}\left\vert\sum_{n=1}^N\cos(nx)\right\vert=\frac{N}{N(x^2+1)}=\frac{1}{x^2+1}$$
for any $N$, in which case we can't make the above arbitrarily small for $x$ fixed.
Graphically, the pointwise limit seems to hold, but I could be mistaken. Any thoughts?
 A: It doesn't converge to zero for $x=2\pi$ for example:
$\frac{1}{N((2\pi)^2+1)}\cdot \sum\limits_{n=1}^N\cos(n\cdot 2\pi)=
\frac{1}{N((2\pi)^2+1)}\cdot \sum\limits_{n=1}^N1=\frac{1}{(2\pi)^2+1}$
A: Half of the Dirichlet Kernel
$$\newcommand{\Re}{\operatorname{Re}}
\begin{align}
\sum_{n=1}^N\cos(nx)
&=\Re\left(\sum_{n=1}^Ne^{inx}\right)\tag1\\
&=\Re\left(\frac{e^{ix}-e^{i(N+1)x}}{1-e^{ix}}\right)\tag2\\
&=\frac{\Re\left(e^{ix}-1-e^{i(N+1)x}+e^{iNx}\right)}{2-2\cos(x)}\tag3\\
&=-\frac12+\frac{\cos(Nx)-\cos((N+1)x)}{2-2\cos(x)}\tag4\\
&=\frac{\sin\left(\left(N+\frac12\right)x\right)}{2\sin\left(\frac12x\right)}-\frac12\tag5
\end{align}
$$
Explanation:
$(1)$: $\cos(x)=\Re\left(e^{ix}\right)$
$(2)$: sum of a geometric series
$(3)$: multiply by $\frac{1-e^{-ix}}{1-e^{-ix}}$
$(4)$: $\cos(x)=\Re\left(e^{ix}\right)$
$(5)$: $\cos(Nx)-\cos((N+1)x)=2\sin\left(\left(N+\frac12\right)x\right)\sin\left(\frac12x\right)$
Note that $(5)$ also follows from the Dirichlet Kernel:
$$
\sum_{n=-N}^N\cos(nx)=\frac{\sin\left(\left(N+\frac12\right)x\right)}{\sin\left(\frac12x\right)}\tag6
$$

Application to the Limit
If $\sin\left(\frac12x\right)\ne0$, then, since $\left|\sin\left(\left(N+\frac12\right)x\right)\right|\le1$,
$$
\begin{align}
\lim_{N\to\infty}\frac1{N\left(x^2+1\right)}\sum_{n=1}^N\cos(nx)
&=\lim_{N\to\infty}\frac1{N\left(x^2+1\right)}\left(\frac{\sin\left(\left(N+\frac12\right)x\right)}{2\sin\left(\frac12x\right)}-\frac12\right)\\[6pt]
&=0\tag6
\end{align}
$$
If $\sin\left(\frac12x\right)=0$, then $x=2\pi k$ for some $k\in\mathbb{Z}$; and thus, $\cos(nx)=1$. Therefore,
$$
\begin{align}
\lim_{N\to\infty}\frac1{N\left(x^2+1\right)}\sum_{n=1}^N\cos(nx)
&=\lim_{N\to\infty}\frac1{N\left(x^2+1\right)}\,N\\[6pt]
&=\frac1{x^2+1}\tag7
\end{align}
$$
