Question about summation of a specific Fourier series I'm interested in the evaluation of the following series
\begin{align}
F(x)=-\frac{1}{L}\sum_{n=-\infty}^{\infty}\frac{e^{ig_{n}x}}{(g_{n}+a)^{2}-b^{2}}, \quad g_{n}=\frac{2\pi}{L}n.
\end{align}
For $x=0$ the series may be evaluated as\begin{align}
-\frac{1}{L }\sum_{n=-\infty}^{\infty}\frac{1}{(g_{n}+a)^{2}-b^{2}}=&\frac{1}{2}\oint_{\gamma}\frac{dz}{2\pi i}\frac{\cot(Lz/2)}{(z+a-b)(z+a+b)}\\
=&-\frac{1}{4b}[\cot(L(a-b)/2)-\cot(L(a+b)/2)].
\end{align}
Here $\gamma$ is the contour encircling the poles at $-a\pm b$ only. The above identity is well known and relies on the fact that an integral of $\pi\cot(\pi z)/p(z), \ p(z)\sim\frac{1}{z^{k>1}}$ over a square contour centered at the origin with side length 2N+1 vanishes in the limit $N\rightarrow\infty$. For non-zero $x$ however, I'm not sure which contour to choose since depending on the sign of $x$ the integral will either converge in the upper or lower half-plane only and thus the previous contour is unsuitable. My other idea was to realize that $F(x)$ satisfies the following integral equation
\begin{align}
\int_{0}^{L}dxF(x)e^{-ig_{n}x}=-\frac{1}{2b}\frac{1}{(g_{n}+a)^{2}-b^{2}}=-\frac{1}{2b}\frac{1}{g_{n}+a-b}+\frac{1}{2b}\frac{1}{g_{n}+a+b}.
\end{align}
The solution is given by
\begin{align}
F(x)=-\frac{ie^{-iax}}{2b}\Bigg(\frac{e^{ibx}}{1-e^{-i(a-b)L}}-\frac{e^{-ibx}}{1-e^{-i(a+b)L}}\Bigg)\\
=-\frac{e^{-ia(x-L/2)}}{4b}\Bigg(\frac{e^{ib(x-L/2)}}{\sin((a-b)L/2)}-\frac{e^{-ib(x-L/2)}}{\sin((a+b)L/2)}\Bigg).
\end{align}
My problem is that this solution does not reduce to the known $x=0$ result at $x=0$, Can someone help?
 A: Too long for a comment.
Your solution is correct: quick check at $x=0$ gives:
$$F(0)=-\frac{i}{2b}\Bigg(\frac{1}{1-e^{-i(a-b)L}}-\frac{1}{1-e^{-i(a+b)L}}\Bigg)=\frac{i}{2b}\Bigg(\frac{1}{1-e^{-i(a+b)L}}-\frac{1}{1-e^{-i(a-b)L}}\Bigg)$$
On the other hand,
$$-\frac{1}{4b}[\cot(L(a-b)/2)-\cot(L(a+b)/2)]=-\frac{i}{4b}\Bigg(\frac{1+e^{-i(a-b)L}}{1-e^{-i(a-b)L}}-\frac{1+e^{-i(a+b)L}}{1-e^{-i(a+b)L}}\Bigg)$$
$$=-\frac{i}{4b}\Bigg(\frac{2+e^{-i(a-b)L}-1}{1-e^{-i(a-b)L}}-\frac{2+e^{-i(a+b)L}-1}{1-e^{-i(a+b)L}}\Bigg)=-\frac{i}{4b}\Bigg(\frac{2}{1-e^{-i(a-b)L}}-1-\frac{2}{1-e^{-i(a+b)L}}+1\Bigg)$$
$$=\frac{i}{2b}\Bigg(\frac{1}{1-e^{-i(a+b)L}}-\frac{1}{1-e^{-i(a-b)L}}\Bigg)$$
But I got the answer for $F(x)$ in a bit different way.
$$F(x)=-\frac{1}{L}\sum_{n=-\infty}^{\infty}\frac{e^{ig_{n}x}}{(g_{n}+a)^{2}-b^{2}}=-\frac{L}{(2\pi)^2}\sum_{n=-\infty}^{\infty}\frac{e^{2\pi i\gamma n}}{(n+\alpha)^{2}-\beta^{2}}$$
Where $\alpha=\frac{aL}{2\pi}$, $\beta=\frac{bL}{2\pi}$, $\gamma=\frac{x}{L}$
Next, we consider the function $g(z)=-\frac{2\pi i}{1-e^{2\pi iz}}$. This function has simple poles with the residues $=1$ at points $n=0, \pm1,\pm2$ ...
Then we integrate in the complex plane along a big circle (with the radius $R\to\infty$):
$$\frac{2\pi iL}{(2\pi)^2}\oint\frac{e^{2\pi i\gamma z}}{(z+\alpha)^{2}-\beta^{2}}\,\frac{2\pi i}{1-e^{2\pi iz}}dz$$
It is easy to show that for $\gamma\in(0;1)$ (or $x\in(0;L)$ ) this integral converges and $\to0$, as $R\to\infty$.
On the other hand, $\oint =0 =2\pi i\sum Res$ inside this big circle.
We immediately get
$$F(x)=-\frac{iL}{2\pi} Res_{(z=-\alpha\pm\beta)}\Big(\frac{e^{2\pi i\gamma z}}{(z+\alpha)^{2}-\beta^{2}}\,\frac{1}{1-e^{2\pi iz}}\Big)$$
$$=\frac{1}{2\beta}e^{-2\pi i\gamma\alpha}\Big(\frac{e^{-2\pi i\gamma\beta}}{1-e^{-2\pi i(\alpha+\beta)}}-\frac{e^{2\pi i\gamma\beta}}{1-e^{-2\pi i(\alpha-\beta)}}\Big)$$
Taking back $x, a$ and $b$
$$F(x)=\frac {ie^{-ixa}}{2b}\Big(\frac{e^{-ibx}}{1-e^{-iL(a+b)}}-\frac{e^{ibx}}{1-e^{-iL(a-b)}}\Big)$$
