Ramanujan's sum related to $\tan^{-1}(e^{-\pi x/2})$ While reading Ramanujan's Collected Papers I came across a nice formula which he mentions without proof $$\tan^{-1}(e^{-\pi x/2}) = \frac{\pi}{4} - \left(\tan^{-1}\frac{x}{1} - \tan^{-1}\frac{x}{3} + \tan^{-1}\frac{x}{5} - \cdots\right)$$ where $x$ is any real number. Ramanujan proves similar formulas with terms involving $\tan^{-1}(x^{2})$ but leaves the above one as if it is obvious.
I tried to simplify RHS term by term starting with $$\frac{\pi}{4} - \tan^{-1}x = \tan^{-1}\frac{1 - x}{1 + x}$$ and then
\begin{align}
RHS &= \frac{\pi}{4} - \tan^{-1}x + \tan^{-1}\frac{x}{3}\notag\\
&= \tan^{-1}\frac{1 - x}{1 + x} + \tan^{-1}\frac{x}{3}\notag\\
&= \tan^{-1}\left(\dfrac{\dfrac{1 - x}{1 + x} + \dfrac{x}{3}}{1- \dfrac{1 - x}{1 + x}\cdot\dfrac{x}{3}}\right)\notag\\
&= \tan^{-1}\left(\dfrac{3 - 2x + x^{2}}{3 + 2x + x^{2}}\right)\notag\\
\end{align}
My guess is that the argument of $\tan^{-1}$ probably looks like some convergent to a suitable continued fraction expansion of $e^{-\pi x / 2}$ but I am just not able to figure it out. An obvious difficulty is that any expansion of $e^{-\pi x / 2}$ as a continued fraction would involve $\pi$ as well as.
Please suggest any other approach to prove the Ramanujan's formula.
Update: If I differentiate with respect to $x$ I get the LHS as $$\frac{-\pi e^{-\pi x / 2}}{2(1 + e^{-\pi x})}$$ and the RHS comes out to be $$-\left(\frac{1}{1 + x^{2}} - \frac{3}{3^{2} + x^{2}} + \frac{5}{5^{2} + x^{2}} - \cdots\right)$$ This is similar to the partial fraction expansion of $\tanh(x)$ given by $$\frac{\tanh x}{8x} = \sum_{k = 1}^{\infty}\frac{1}{(2k - 1)^{2}\pi^{2} + 4x^{2}}$$ but not exactly as desired. For the proof of formula for $\tanh x$ see this.
 A: If we differentiate both terms, we get an identity that can be easily proved by considering the logarithmic derivatives of the Weierstrass products for the $\sinh$ and $\cosh$ functions. 
We just need to prove:
$$ \sum_{n\geq 0}\frac{(-1)^n}{(2n+1)+\frac{z^2}{2n+1}} = \frac{\pi}{4\cosh\frac{\pi z}{2}}.\tag{1}$$
From:
$$\cot z = \sum_{k\in\mathbb{Z}}\frac{1}{z-k\pi},\qquad \frac{1}{\sin z}=\sum_{k\in\mathbb{Z}}\frac{(-1)^k}{z-k\pi}\tag{2}$$
it follows that:
$$ \frac{\pi}{2\sin \frac{\pi z}{2}}=\sum_{k\in\mathbb{Z}}\frac{(-1)^k}{ z-2k}\tag{3}$$
and by replacing $z$ with $z-1$ we also have:
$$ -\frac{\pi}{2\cos \frac{\pi z}{2}}=\sum_{k\in\mathbb{Z}}\frac{(-1)^k}{ z-(2k+1)}\tag{4}$$
so we just need to replace $z$ with $iz$ to get $(1)$. 
By integrating both sides of $(1)$ between $0$ and $x$ Ramanujan's identity follows, since:
$$ \int\frac{\pi\,dz}{4\cosh\frac{\pi z}{2}} = \arctan\left(\tanh\frac{\pi z}{4}\right)=\frac{\pi}{4}-\arctan(e^{-\pi z/2}).\tag{5}$$

Another way to prove $(1)$ is to notice that, through the Laplace transform of $\cos x$:
$$\int_{0}^{+\infty}\frac{\cos (\alpha x)}{e^x+e^{-x}}\,dx =\sum_{k\geq 0}(-1)^k\int_{0}^{+\infty}e^{-(2k+1)x}\cos(\alpha x)\,dx = \sum_{k\geq 0}\frac{(-1)^k (2k+1)}{\alpha^2+(2k+1)^2}$$
but the LHS can be also computed through the residue theorem. 
That was exactly the point of a currently deleted question.
