Delta function and $\sum_{t}\exp\{ i k t\} $ I am interested in evaluating the following, which appears in an integrand,
$$
\sum_{t=0}^{\infty}e^{ikt}
$$
where $k$ is real. Using the following relation
$$
\sum_{t=-\infty}^{\infty}e^{ikt} = 2\pi\delta(k),
$$
the real part of it is
\begin{eqnarray}
\Re\left[\sum_{t=0}^{\infty}e^{ikt}\right]&=&\frac{1}{2}+\frac{1}{2}\Re\left[\sum_{t=-\infty}^{\infty}e^{ik}\right]\\&=&\frac{1}{2}+\pi\delta(k).
\end{eqnarray}
Note the addition of $\frac{1}{2}$ term! This $\frac{1}{2}$ term does not agree with the following derivation using $\epsilon$ trick!
\begin{eqnarray}
\lim_{\epsilon\rightarrow0_{+}}\lim_{T\rightarrow\infty}\sum_{t=0}^{T}e^{ikt}e^{-\epsilon t}&=&\lim_{\epsilon\rightarrow0_{+}}\lim_{T\rightarrow\infty}\frac{e^{\epsilon}-e^{ik\left(T+1\right)}e^{-\epsilon T}}{e^{\epsilon}-e^{ik}}\\
&=&\lim_{\epsilon\rightarrow0_{+}}\frac{1}{e^{\epsilon}-e^{ik}}
\end{eqnarray}
which becomes, when $k \rightarrow 0$,
\begin{eqnarray}
\lim_{k\rightarrow0,}\lim_{\epsilon\rightarrow0_{+}}\frac{1}{e^{\epsilon}-e^{ik}}&=&\lim_{k\rightarrow0,}\lim_{\epsilon\rightarrow0_{+}}\frac{1}{\epsilon-ik}\\
&=&\lim_{k\rightarrow0}\lim_{\epsilon\rightarrow0_{+}}\frac{i}{k+i\epsilon}\\&=&\lim_{k\rightarrow0}\left[\pi\delta\left(k\right)+i\mathcal{P}\frac{1}{k}\right]
\end{eqnarray}
where Sokhotsky's formula is used.
Now when $k\nrightarrow0$,
$$
\lim_{\epsilon\rightarrow0_{+}}\frac{1}{e^{\epsilon}-e^{ik}}=\frac{1}{1-e^{ik}}
$$
Therefore, for all $k$,
$$
\sum_{t=0}^{\infty}e^{ikt}=\pi\delta\left(k\right)+\mathcal{P}\frac{1}{1-e^{ik}}
$$
Note that the real part of it does not have $\frac{1}{2}$ addition term, instead has $\Re\mathcal{P}\frac{1}{1-e^{ik}}$.
What am I doing wrong?

Building on Svyatoslav's answer which in turn supported by vitamin d, the conclusion is the following:
$$
\sum_{t=0}^{\infty}e^{ikt} = \frac{1}{2} + \pi \delta(k) + \frac{i}{2} \mathcal{P} \cot (k/2)
$$

The Dirichlet Kernel is a Fourier Series approximations to the Dirac delta. It relies on cancellation rather than decay away from $0$. The Fejér Kernel makes a better approximation to the Dirac delta since it is positive and decays to $0$ away from $0$.
$$
\sum_{k=-n}^ne^{ikx}=\underbrace{\frac{\sin\left(\frac{2n+1}2x\right)}{\sin\left(\frac12x\right)}}_{2\pi\times\text{Dirichlet Kernel}}
$$
If we multiply this by $e^{inx}$ we get
$$
\begin{align}
\sum_{k=0}^{2n}e^{ikx}
&=\frac{\sin\left(\frac{2n+1}2x\right)}{\sin\left(\frac12x\right)}\,e^{inx}\\[3pt]
&=\frac12\left(\vphantom{\frac{\frac12}{\frac12}}\!\right.\underbrace{\frac{\sin\left(\frac{4n+1}2x\right)}{\sin\left(\frac12x\right)}}_{2\pi\times\text{Dirichlet Kernel}}+1\left.\vphantom{\frac{\frac12}{\frac12}}\!\right)+\frac i2\cot\left(\frac12x\right)\left(\vphantom{\frac{\frac12}{\frac12}}\!\right.1-\underbrace{\frac{\cos\left(\frac{4n+1}2x\right)}{\cos\left(\frac12x\right)}}_{\substack{2\pi\times\text{Dirichlet Kernel}\\\text{rotated by $\pi$,}\\\text{which is killed}\\\text{by $\cot\left(\frac12x\right)$}}}\left.\vphantom{\frac{\frac12}{\frac12}}\!\right)
\end{align}
$$
So the real part tends to $\frac12(2\pi\delta+1)$ the imaginary part tends to $\frac12\cot\left(\frac12x\right)$.


