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.