The most complex formula for the golden ratio $\varphi$ that I have ever seen. How was it achieved?

I am fascinated by the following formula for the golden ratio $\varphi$: $$\Large\varphi = \frac{\sqrt{5}}{1 + \left(5^{3/4}\left(\frac{\sqrt{5} - 1}{2}\right)^{5/2} - 1\right)^{1/5}} - \frac{1}{e^{2\pi\,/\sqrt{5}}}\,\mathop{\LARGE \mathrm{K}}_{n=0}^{\infty}e^{-2\pi n\sqrt{5}}$$ such that $$\Large{\mathop{\LARGE\mathrm K}_{n=0}^{\infty}e^{-2\pi n\sqrt{5}} = \cfrac{1}{1 + \frac{e^{-2\pi\sqrt{5}}}{1 + \frac{e^{-4\pi\sqrt{5}}}{1 + \cdots}}}}.$$ This formula is just a rearrangement of a formula giving the value of the continued fraction, and was to no surprise created by Srinivasa Ramanujan.

My question is, just how on Earth did he create something like this? Is there some explanation? Does anybody know?? I did some research and he had three other very similar formulae, where in each of them, he showed the values of $$\large\mathop{\LARGE \mathrm K}_{n=0}^\infty e^{-2\pi n}\quad\text{and}\quad e^{-2\pi/5}\mathop{\LARGE \mathrm K}_{n=0}^\infty e^{-2\pi n}\quad\text{and}\quad e^{-\pi/5}\mathop{\LARGE\mathrm K}_{n=0}^\infty e^{-\pi n}$$ and so many other summations regarding Gelfond's constant $e^\pi$. I apologise if, in the event you know how he created his formula, you might be sitting at your desk for hours writing a long long answer with the workings out.

• Huh? ${}{}{}{}$ – Mariano Suárez-Álvarez Feb 18 '18 at 5:01
• See this blog post for the proof by Ramanujan. Ramanujan was systematically investigating the properties of Rogers Ramanujan continued fraction $R(q)$ and he found that it was also a modular function which allowed its values to be computed as algebraic numbers for $q=\pm e^{-\pi\sqrt{n}}$ where $n$ is a positive rational number. – Paramanand Singh Feb 24 '18 at 8:02