How did Ramanujan came up with this? The following is a picture of equation from Ramanujan's lost notebook. In this page, Ramanujan gives a closed form for,
$$\sum_{n\geq 1}\sigma_{s}(n)x^{n}$$



In an attempt initially it's claimed that,
$$\pi+2\pi\sum_{n\geq 1}e^{-2n\pi x}=\frac{1}{x}+\frac{1}{x+i}+\frac{1}{x-i}+\frac{1}{x+2i}+\frac{1}{x-2i}+
\cdots$$

*

*I am not sure how to prove this. Moreover After EQ.$(9.2.2)$, he also claims the following fact, $$\sum_{n\geq 1}\sigma_{s-1}(n)e^{-2\pi nx}=\sum_{n\geq 1}\left(1^{s-1}e^{-2\pi nx}+2^{s-1}e^{-4\pi nx}+\cdots\right)$$


*I am also unaware how to prove this?
All of my attempts were flawed and were not bearing something new, but rather bringing me where I started from. (Hence I am not mentioning them here).
 A: This just answers the first part of the question.
$$
\frac{1}{x}+\frac{1}{x+i}+\frac{1}{x-i}+\frac{1}{x+2i}+\frac{1}{x-2i}+
...=\frac{1}{x}+2\sum_{n=1}^\infty {x\over x^2+n^2}
\\
=\pi\coth\pi x,
$$
using this, which shows that
$$
\begin{align}
\sum_{n=1}^\infty \frac{y}{y^2+n^2}
 &= - \frac{1}{2} \frac{1}{y} + \frac{1}{2} \pi\coth(\pi y)\\
\end{align}
$$
using complex analysis,
$$
\\
=\pi {1+e^{-2\pi x}\over 1-e^{-2\pi x}}\\
=\pi {1-e^{-2\pi x} + 2 e^{-2\pi x}\over 1-e^{-2\pi x}}
\\
=\pi + 2\pi\sum_{n=1}^\infty e^{-2n\pi x},
$$
using the geometric expansion $\sum_{i=1}^\infty r^n={r\over 1-r}$
backwards.
A: For 2. you need to apply the residue theorem to $$\int_C \frac{t^{-s}}{e^{t+2\pi x}-1}dt
= (e^{-2\pi s}-1) \int_0^\infty \frac{t^{-s}}{e^{t+2\pi x}-1}dt$$ $$
= (e^{-2\pi s}-1) \sum_{n\ge 1} \int_0^\infty t^{-s} e^{-nt-2\pi n x} dt = 
(e^{- 2\pi s}-1) \sum_{n\ge 1}\Gamma(1-s)e^{-2\pi n x} n^{s-1}
$$
Where $C$ is a contour enclosing $[0,\infty)$ positively.
Then use the reflection formula for $\Gamma$.
