How does the divergent sum $\sum_{n=1}^\infty\cos(2n\gamma)\sin(2nt)$ correctly evaluate an integral? Surely distributions don’t apply here $\newcommand{\d}{\,\mathrm{d}}\newcommand{\res}{\operatorname{Res}}$Note: I don’t know any distribution theory myself, but I was informed by someone else and hinted to by this answer that my problem could involve distributions. I associate distributions (at a long arm’s length) with integrals: I have absolutely no idea how a distributionally convergent sum could correctly evaluate an integral, and I still have no idea why a convergent integral would produce a divergent residue series (this surely contradicts the residue theorem, right?).
When inspecting this post, I thought it was a great example for me to practice my contour integration:

Show that: $$\int_{-\infty}^\infty e^{-\lambda t}\cdot\frac{\sinh(\lambda(\pi/2-\gamma))}{\sinh(\pi\lambda/2)}\d\lambda=\frac{\sin(2\gamma)}{\sin(\gamma+t)\sin(\gamma-t)}$$Where $t,\gamma\in\Bbb R$ and  $0\lt|t|\lt\gamma\lt\frac{\pi}{2}$.

After some thought it is possible to see that the integrand exponentially decays when $t,\gamma$ are such. Thus we can use the lazy upper-semicircular contour without further ado, and we find that the integral is equal to the sum of residues at all the poles with positive imaginary part (the singularity at $\lambda=0$ is removable). The poles are precisely when $\sinh(\pi\lambda/2)=0$, or when $i\sin(i\pi\lambda/2)=0$, so that $\lambda=2ni,\,n\in\Bbb N$ are the poles.
The poles at such $\lambda$ are simple - therefore the residues are easily found by: $$\begin{align}\res_{\lambda=2ni}&=\lim_{\lambda\to 2ni}e^{-\lambda t}\sinh(\lambda(\pi/2-\gamma))\cdot\frac{\lambda-2ni}{\sinh(\pi\lambda/2)}\\&=e^{-2ni t}\sinh(\pi ni-2ni\gamma)\cdot\frac{1}{\frac{\pi}{2}\cosh(\pi ni)}\\&=-\frac{2}{\pi}\sinh(2ni\gamma)e^{-2ni t}\\&=-\frac{2i}{\pi}\sin(2n\gamma)e^{-2nit}\end{align}$$And so the integral is just, I think: $$\sum_{n=1}^\infty4\sin(2n\gamma)e^{-2nit}$$But something is amiss here. The summands do not tend to $0$, and this is a typical example of a divergent oscillatory sum. I, at this point, gave up, thinking I had erred in my method somehow. However, I did check Wolfram, just in case. Online Wolfram did that weird thing where it wilfully misunderstood every command, so I converted the exponential into cosine and sines. Since the integrand and the integral is clearly real, I just assumed that: $$\sum_{n=1}^\infty\sin(2n\gamma)\sin(-2nt)\overset{?}{=}0\quad\text{Which Wolfram corroborates...}$$And it remained to calculate: $$4\sum_{n=1}^\infty\cos(2nt)\sin(2n\gamma)$$Again, this sum is divergent, but I kept following Wolfram: $$4\sum_{n=1}^\infty\cos(2nt)\sin(2n\gamma)\overset{?}{=}\frac{\sin(2\gamma)}{\sin(\gamma+t)\sin(\gamma-t)}$$Which is, in my opinion, nonsense. Plotting the partial sums on any graph and it is evident that the sum doesn't converge. Calculating the partial sums for oneself gives the same conclusion.
I have three linked questions about this:

*

*What kind of divergent summation technique is Wolfram applying, to get the cosine/sine sum as finite and the sine/sine sum as $0$?

*Why did the contour integral produce a divergent series, despite the contour integral being itself convergent?

*Is it a mathematical coincidence that the divergent summation formula produces the correct answer?

Many thanks. This is confusing me greatly.
 A: $\newcommand{\d}{\,\mathrm{d}}$The integrand is not, in fact, exponentially dominated on the complex plane. More precisely, calling the integrand $f(\lambda)$, we have: $$f(\lambda)=\frac{e^{\pi\lambda}e^{(t-\gamma)\lambda}-e^{\lambda(t+\gamma)}}{e^{\pi\lambda}-1}=\frac{e^{(t-\gamma)\lambda}-e^{\lambda(t+\gamma)}e^{-\pi\lambda}}{1-e^{-\pi\lambda}}$$And as $0\lt|t|\lt\gamma\lt\frac{\pi}{2}$, $-\pi\lt-2\gamma\lt t-\gamma\lt0$ and $0\lt t+\gamma\lt2\gamma\lt\pi$, so $f$ exponentially tends to $0$ as $\lambda\to\pm\infty$. However, letting $\lambda=x+iy$, $x,y\in\Bbb R$, and we notice that, if $x\neq0$, the exponential decay still occurs, albeit not uniformly in any deleted neighbourhood of the origin - and if $x=0$ the exponential decay does not occur. So, what I called the "lazy semicircular contour" was as lazy as it always is - I didn't bother to check, and this technique fails.
However, credit to the (I believe they are a MSE user) Brok, we can regularise the integral by integrating: $$g(\lambda)=e^{i\alpha\lambda}f(z)$$For real positive $\alpha$. As the modulus of this over the domain of integration is always that of $f$, the dominated convergence theorem applies and we may compute the integral of $f$ as the limit of the integral of $g$ as $\alpha\to0$. For $\mathrm{Arg}\lambda\approx\frac{\pi}{2}$ this new $g$ function features $e^{i\alpha x-\alpha y}$ which exponentially decays in the limit as the radius tends to infinity and allows the contour method to succeed, and it introduces an additional term $e^{-2n\alpha}$ in the residue calculation.
Then: $$\int_{-\infty}^\infty\,g(\lambda)\d\lambda=4\cdot\sum_{n=1}^\infty e^{-2n(\alpha+it)}\sin(2n\gamma)$$
Which does converge! It equals: $$\begin{align}\frac{2}{i}\left(\sum_{n=1}^\infty e^{n(2i\gamma-2\alpha-2it)}-\sum_{n=1}^{\infty}e^{n(-2i\gamma-2it-2\alpha)}\right)&=\frac{2}{i}\left(\frac{e^{-2\alpha}e^{2i\gamma-2it}}{1-e^{-2\alpha}e^{2i\gamma-2it}}-\frac{e^{-2\alpha}e^{-2i\gamma-2it}}{1-e^{-2\alpha}e^{-2i\gamma-2it}}\right)\\&\to\frac{2}{i}\cdot\frac{e^{2i(\gamma-t)}-e^{-2i(\gamma+t)}+e^{-4it}-e^{-4it}}{1+e^{-4it}-e^{2i(\gamma-t)}-e^{-2i(\gamma+t)}}\\&=\frac{2}{i}\cdot\frac{e^{-2it}(2i\sin(2\gamma))}{e^{-2it}(2\cos(2t))-e^{-2it}(2\cos(2\gamma))}\\&=2\cdot\frac{\sin(2\gamma)}{-2\sin(\gamma+t)\sin(t-\gamma)}\\&=\frac{\sin(2\gamma)}{\sin(\gamma+t)\sin(\gamma-t)}\quad\blacksquare\end{align}$$
I still don't know what the linked answer meant by distributionally convergent though... perhaps someone knows a clever distribution perspective on all this.
A: If you replace the parameters with actual values, WolframAlpha says that it's using Dirichlet regularization, that is, assigning the value $$\lim_{s \to 0^{+}} \sum_{n=1}^{\infty}\frac{f(n)}{n^{s}} $$ to the series $ \sum_{n=1}^{\infty} f(n). $
I'll show that $$\lim_{s \to 0^{+}}\sum_{n=1}^{\infty} \frac{4 \sin(2n \gamma) e^{-2nit}}{n^{s}}= \frac{\sin(2 \gamma)}{\sin(\gamma +t) \sin(\gamma-t)} . $$

In this answer, I showed that $\operatorname{Li}_{s}(z)$ is a continuous function in $s$ in the half-plane $\Re(s) >-1$ for all values of $z$ except $z$ real and $\ge 1.$
Therefore,
$$ \begin{align}  \lim_{s \to 0^{+}} \sum_{n=0}^{\infty}\frac{4\sin(2n \gamma) e^{-2nit}}{n^{s}} &= 4\lim_{s \to 0^{+}} \sum_{n=1}^{\infty}\frac{\left(e^{2ni \gamma}-e^{-2ni \gamma} \right)e^{-2nit}}{2in^{s}}  \\ &= \frac{4}{2i} \lim_{s \to 0^{+}}\sum_{n=1}^{\infty} \frac{e^{2ni(\gamma-t)}-e^{-2ni(\gamma+t)}}{n^{s}}  \\ &= \frac{4}{2i} \lim_{s \to 0^{+}} \left(\operatorname{Li}_{s} \left(e^{2i(\gamma-t)} \right) - \operatorname{Li}_{s} \left(e^{-2i(\gamma+t)} \right)\right) \\ &= \frac{4}{2i}  \left(\operatorname{Li}_{0} \left(e^{2i(\gamma-t)} \right) - \operatorname{Li}_{0} \left(e^{-2i(\gamma+t)} \right)\right) \\ &= \frac{4}{2i} \left(\frac{e^{2i(\gamma-t)}}{1-e^{2i(\gamma-t)}} - \frac{e^{-2i(\gamma+t)}}{1-e^{-2i(\gamma+t)}} \right)  \\ &= \frac{4}{2i} \left(\frac{e^{2i(\gamma-t)} -e^{-2i(\gamma+t)}}{1-e^{-2i(\gamma+t)} -e^{2i(\gamma-t)} +e^{-4i t}}\right) \\ &= \frac{4}{2i} \left(\frac{e^{2i \gamma}-e^{-2i \gamma}}{e^{2i t} -e^{-2i\gamma}-e^{2i \gamma}+e^{-2it}} \right) \\ &=  \frac{2 \sin(2 \gamma)}{\cos(2 t)- \cos(2 \gamma)} \\ &= \frac{\sin(2 \gamma)}{\sin(\gamma +t) \sin(\gamma-t)}. \end{align}$$
A: Evaluating the series in a distributional sense means that the terms are evaluated first, and then the series convergence is evaluated.
That is, if $\phi$ is a test function, smooth with finite support, then
$$
\langle T,\phi\rangle = \sum_{n=1}^\infty c_n(γ)⟨s_n,ϕ⟩
$$
where $T$ is the series expression interpreted as distribution, $c_n(t)=\cos(2\pi nt)$, $s_n(t)=\sin(2\pi nt)$, $⟨T,ϕ⟩$ is the application of this linear functional to $ϕ$.
As the Fourier sine coefficients $⟨s_n,ϕ⟩=\frac{i}{2}(\hatϕ(n)-\hatϕ(-n))$, with exponential Fourier coefficients
$$
\hat \phi(n)=\int e^{-2\pi i nt}ϕ(t)\,dt,
$$
are a fast-falling sequence due to the smoothness of $\phi$, the cosine series with them converges absolutely.

From the Fourier expansion theorems we also know that
$$
\sum_{n\in\Bbb Z}\hatϕ(n)e^{i2\pi\,nt}=\sum_{k\in\Bbb Z}\phi(t+k),
$$
Now for the terms we get
$$
c_n(γ)⟨s_n,ϕ⟩=\frac{i}{4}(e_n(γ)+e_{-n}(γ))(\hatϕ(n)-\hatϕ(-n)
$$
in total thus
$$
\frac{i}{4}\sum_{n=1}^\infty \hatϕ(n)((e_n(γ)+e_n(-γ))-\frac{i}{4}\sum_{n=1}^\infty \hatϕ(-n)((e_{-n}(γ)+e_{-n}(-γ))
$$
I think this is the even part of the Hilbert transform of the periodization of $\phi$.
