Infinite summation : $\displaystyle S= \sum_{r=0}^{\infty} \frac{\cos (2xr)}{4r^2 - 1}$ So I ran into this problem on Quora:

$$\displaystyle S = \sum_{r=0}^{\infty} \frac{\cos (2xr)}{4r^2 - 1}$$

Initially I thought it cannot be resolved as telescoping method failed. But I tried something else.
MY ATTEMPT:
Let $\displaystyle S = \mathbb{R} \left [ \sum_{r=0}^{\infty} \frac {e^{-\iota 2rx}}{4r^2 -1} \right ] \equiv \mathbb{R} [J], \ $ where$ \ \mathbb{R} \ $ shows real part.
So let us find $J.$
Now, $\displaystyle J(x) = \sum_{r=0}^{\infty} \frac {e^{-\iota 2rx}}{4r^2 -1} \implies J'(x) = \sum_{r=0}^{\infty} \frac {-\iota  (2r)e^{-\iota 2rx}}{4r^2 -1} \ $ and hence
$\displaystyle J''(x) = -\sum_{r=0}^{\infty} \frac {(4r^2)e^{-\iota 2rx}}{4r^2 -1}.$
Therefore some maipulations and we get:
$$\displaystyle J'' + J =  - \sum_{r=0}^{\infty} e^{-\iota 2rx} \implies J'' + J =  \iota \sin(x) e^{-\iota x}.$$
We can solve this by variation of parameters:
Initial soltuions of the equation $\ \displaystyle J'' + J = 0 \ $ are $\displaystyle e^{\iota x} , e^{-\iota x} $. And let $\ \displaystyle J= C_0 e^{\iota x} \phi_1 + C_1 e^{-\iota x} \phi_2 \ $ satisfy $ \ \displaystyle J'' + J =  \iota \sin(x) e^{-\iota x}. \ $
Therefrore,
$$\displaystyle 
e^{\iota x} \phi_1' +  e^{-\iota x} \phi_2' = 0 \\
e^{\iota x} \phi_1' -  e^{-\iota x} \phi_2' = \sin(x) e^{-\iota x} 
$$
Solving for $ \ \displaystyle \phi_1 , \phi_2\ $ we get:

$$\displaystyle J = C_0 e^{\iota x}\left ( \frac{1}{6} \cos (x) + \frac{1}{3} \sin ^2(x)  e^{\iota x} \right ) + \frac{C_1}{2} e^{-\iota x} \cos (x)$$


But the issue is $ \ \displaystyle  C_0 , C_1 .\ $ I was only able to find that $ \ \displaystyle  C_0 + 3C_1 = 3 ,\ $ using the condition :$\displaystyle J(x=0) = J(x=\pi) = J(x=-\pi) = \frac{1}{2} = \frac{C_0}{6} + \frac{C_1}{2}$
I was only able to conclude:

$$\displaystyle  S = \mathbb{R} \left[ C_0 e^{\iota x}\left ( \frac{1}{6} \cos (x) + \frac{1}{3} \sin ^2(x)  e^{\iota x} \right ) + \frac{C_1}{2} e^{-\iota x} \cos (x) \right] \\ \text{where} \ C_0 + 3C_1 = 3 $$


I want anyone guide me further. Or suggest some another method to solve this.
 A: $$2\sum_{r=0}^\infty\dfrac{e^{2irx}}{4r^2-1}=\sum_{r=0}^\infty\dfrac{e^{2irx}}{2r-1}-\sum_{r=0}^\infty\dfrac{e^{2irx}}{2r+1}$$
Now $$\sum_{r=0}^\infty\dfrac{e^{2irx}}{2r-1}=-1+e^{ix}\sum_{r=1}^\infty\dfrac{e^{ix(2r-1)}}{2r-1}$$
$$=-1+e^{ix}\ln\dfrac{1+e^{ix}}{1-e^{ix}}$$
$$=-1+e^{ix}\left(i\pi+\ln\dfrac{e^{ix/2}+e^{-ix/2}}{e^{ix/2}-e^{-ix/2}}\right)\text{ using }\ln(1-y)=-\sum_{n=1}^\infty\dfrac{y^r}r$$
$$=-1+e^{ix}\left(i\pi-\dfrac{i\pi}2+\ln\cot\dfrac x2\right)$$
The real part will be $$-1+\cos x\cdot\ln\cot\dfrac x2-\dfrac\pi2\cdot\sin x$$
Similarly, calculate $$\sum_{r=0}^\infty\dfrac{e^{2irx}}{2r+1}$$
A: Below is presented one of the way - how the problem can be solved via the complex integration. This solution I also posted on Quora.
Let's consider
$\displaystyle S_0=\sum_{r=1}^\infty\frac{\cos 2rx}{4r^2-1}=\frac{1}{2}\Big(\Re\sum_{r=-\infty}^\infty\frac{e^{2irx}}{4r^2-1}+1\Big)=\frac{1}{2}(\Re S+1)\tag*{}$
To evaluate $S=\sum_{r=-\infty}^\infty\frac{e^{2irx}}{4r^2-1}$ we introduce the function $g(z)=\frac{2\pi i}{e^{2\pi iz}-1}$, which has the residues $\operatorname{Res}g(z)=1$ at the points $s=0,\pm1,\pm2 ...$
Let's consider
$\displaystyle I=\oint \frac{2\pi i}{e^{2\pi iz}-1}\frac{e^{2izx}}{4z^2-1}dz\tag*{}$
where we impose the condition $x\in[0;\pi]$, and the integration is along a contour that encloses the axis $X$ (red contour on the picture below). It also encloses all the poles of the function (because they lie on the axis $X$).

Then we can deform the contour - making a circle of radius $R\to\infty$.
Due to the requirement $x\in[0;\pi]\,\,\, |\frac{1}{e^{2\pi iz}-1}\frac{e^{2izx}}{4z^2-1}|<|\frac{1}{4z^2-1}|\sim \frac{1}{R^2}$ at $R\to\infty$, and, therefore, $I\to0$ at $R\to\infty$.
It means that
$\displaystyle I=\oint=\sum\operatorname{Res}\frac{2\pi i}{e^{2\pi iz}-1}\frac{e^{2izx}}{4z^2-1}=0\tag*{}$
On the other hand,
$\displaystyle \sum\operatorname{Res}\frac{2\pi i}{e^{2\pi iz}-1}\frac{e^{2izx}}{4z^2-1}=\sum\operatorname{Res}_{z=\pm1/2}\frac{2\pi i}{e^{2\pi iz}-1}\frac{e^{2izx}}{4z^2-1}+S\tag*{}$
Therefore,
$\displaystyle S=-\operatorname{Res}_{z=\pm1/2}\frac{2\pi i}{e^{2\pi iz}-1}\frac{e^{2izx}}{4z^2-1}\tag*{}$
The residues evaluation is straightforward:
$\displaystyle S=-2\pi i\Big(\frac{e^{ix}}{4(e^{\pi i}-1)}+\frac{e^{-ix}}{(-4)(e^{-\pi i}-1)}\Big)=-\frac{\pi}{2}\sin x\tag*{}$
and the sum $S_0$
$\displaystyle S_0=\frac{1}{2}(\Re S+1)=\frac{1}{2}(1-\frac{\pi}{2}\sin x); \,\,x\in[0;\pi]\tag*{}$
Then $$\sum_{r=0}^\infty\frac{\cos 2rx}{4r^2-1}=S_0-1=-\frac{1}{2}(1+\frac{\pi}{2}\sin x); \,\,x\in[0;\pi]$$
We can rewrite the answer for $x\in[-\pi;\pi]$ as
$\displaystyle \boxed{\,\,\sum_{r=0}^\infty\frac{\cos 2rx}{4r^2-1}=-\frac{1}{2}\big(1+\frac{\pi}{2}|\sin x|\big); \,\,x\in[-\pi;\pi]\,\,}\tag*{}$
A: Putting it as a comment may be too long, since this sum seems to be not a trivial one. Thus I provide a closed form here, obtained by CAS (which is large even without a step-by-step solution):
$$\sum _{r=1}^{\infty} \frac{\cos (2 r x)}{4 r^2-1}=\\-\frac{1}{4} e^{-i x} \left(-2 e^{i x}+e^{2 i x} \tanh ^{-1}\left(e^{-i x}\right)-\tanh ^{-1}\left(e^{-i x}\right)-e^{2 i x} \tanh ^{-1}\left(e^{i x}\right)+\tanh ^{-1}\left(e^{i x}\right)\right)$$
The sum up to $k$ involves the Lerch transcendent $\Phi$ and looks as follows:
$$\sum _{r=1}^k \frac{\cos (2 r x)}{4 r^2-1}=\\-\frac{1}{8 (2 k+1)}e^{-4 i x} \left(-2 k \left(e^{-2 i x}\right)^{k-1} \Phi \left(e^{-2 i x},1,k+\frac{3}{2}\right)-\left(e^{-2 i x}\right)^{k-1} \Phi \left(e^{-2 i x},1,k+\frac{3}{2}\right)+2 k \left(e^{-2 i x}\right)^k \Phi \left(e^{-2 i x},1,k+\frac{3}{2}\right)+\left(e^{-2 i x}\right)^k \Phi \left(e^{-2 i x},1,k+\frac{3}{2}\right)-e^{6 i x} \left(e^{2 i x}\right)^k \Phi \left(e^{2 i x},1,k+\frac{3}{2}\right)+e^{8 i x} \left(e^{2 i x}\right)^k \Phi \left(e^{2 i x},1,k+\frac{3}{2}\right)-2 k e^{6 i x} \left(e^{2 i x}\right)^k \Phi \left(e^{2 i x},1,k+\frac{3}{2}\right)+2 k e^{8 i x} \left(e^{2 i x}\right)^k \Phi \left(e^{2 i x},1,k+\frac{3}{2}\right)+2 \left(e^{-2 i x}\right)^{k-1}+2 e^{6 i x} \left(e^{2 i x}\right)^k-8 k e^{4 i x}-4 k e^{3 i x} \tanh ^{-1}\left(e^{-i x}\right)+4 k e^{5 i x} \tanh ^{-1}\left(e^{-i x}\right)+4 k e^{3 i x} \tanh ^{-1}\left(e^{i x}\right)-4 k e^{5 i x} \tanh ^{-1}\left(e^{i x}\right)-4 e^{4 i x}-2 e^{3 i x} \tanh ^{-1}\left(e^{-i x}\right)+2 e^{5 i x} \tanh ^{-1}\left(e^{-i x}\right)+2 e^{3 i x} \tanh ^{-1}\left(e^{i x}\right)-2 e^{5 i x} \tanh ^{-1}\left(e^{i x}\right)\right)$$
To resolve this in detail (step by step), a closer look at the Lerch transcendent might give insights into the sum.
