<s>[INST] Ramanujan's $\sqrt{\frac{\pi e}{2}}$ formula The following identity is due to Ramanujan:
$$\DeclareMathOperator{\k}{\vphantom{\sum}\vcenter{\LARGE K}} \sqrt{\frac{\pi e}{2}}=\frac{1}{1+\k_{n=1}^\infty \frac{n}{1}}+\sum_{n=0}^\infty\frac{1}{(2n+1)!!}$$
or
$$\sqrt{\frac{\pi e}{2}}=\cfrac{1}{1+\cfrac{1}{1+\cfrac{2}{1+\cfrac{3}{\ddots}}}}+1+\frac{1}{1\cdot 3}+\frac{1}{1\cdot 3\cdot 5}+\cdots $$
I'm interested in the proof of this identity, but I couldn't manage to find any reference except for the linked page.
 [/INST] As pointed out by the linked page, it suffices to prove
$$ 1+\dfrac{1}{1+\dfrac{2}{1+\dfrac{3}{1+\ddots}}} = \sqrt{\frac{2}{\pi e}} \frac{1}{\operatorname{erfc}(1/\sqrt{2})}. \tag{1} $$
To this end, we will resort to the standard theory of continued fraction. Define $(p_n)$ and $(q_n)$ by the following relation:
$$
\begin{pmatrix} p_n \\ q_n \end{pmatrix} = A_1A_2\dots A_n \begin{pmatrix} 1 \\ 0 \end{pmatrix}
\quad\text{where}\quad
A_n = \begin{pmatrix} 1 & n \\ 1 & 0 \end{pmatrix}.
$$
Then it is routine to check that
\begin{align*}
p_0 &= 1, & p_1 &= 1, & p_{n+2} &= p_{n+1} + (n+1) p_n, \\
q_0 &= 0, & q_1 &= 1, & q_{n+2} &= q_{n+1} + (n+1) q_n.
\end{align*}
Moreover, if $f_A(z) = \frac{a_{11}z+a_{12}}{a_{21}z+a_{22}}$ denotes the linear fractional transformation induced by the $2\times2$ matrix $A=[a_{ij}]_{1\leq i,j\leq 2}$, then we have:
$$ \frac{p_n}{q_n} = f_{A_1\dots A_n}(\infty) = (f_{A_1}\circ\dots\circ f_{A_n})(\infty) = 1+\dfrac{1}{1+\dfrac{2}{\ddots+\dfrac{\ddots}{1+\dfrac{n-1}{1}}}} $$
The standard theory also affirms that this converges as $n\to\infty$. So it suffices to compute the limit as $n\to\infty$. To this end, note that both $p_n$ and $q_n$ are increasing and diverges to $\infty$. Moreover, if we introduce the exponential generating functions of $(p_n)$ and $(q_n)$ by
$$ y_p (x) = \sum_{n=0}^{\infty} \frac{p_n}{n!}x^n \quad\text{and}\quad y_q (x) = \sum_{n=0}^{\infty} \frac{q_n}{n!}x^n, $$
then they satisfy
$$ y_p' = (1+x)y_p \quad\text{and}\quad y_q' = 1 + (1+x)y_q. $$
These equations, together with the initial conditions $y_p(0) = p_0 = 1$ and $y_q(0) = q_0 = 0$, can be solved by the integrating factor method, and we obtain
$$ y_p(x) = e^{x+\frac{x^2}{2}} \quad \text{and} \quad y_q(x) = e^{x+\frac{x^2}{2}}\sqrt{\frac{\pi e}{2}} \left( \operatorname{erf}\left(\frac{1+x}{\sqrt{2}}\right) - \operatorname{erf}\left(\frac{1}{\sqrt{2}}\right) \right). $$
Now by invoking the standard argument for abelian theorem,
$$ \lim_{n\to\infty} \frac{p_n}{q_n} = \lim_{x\to\infty} \frac{y_p(x)}{y_q(x)} = \sqrt{\frac{2}{\pi e}} \frac{1}{\operatorname{erfc}\left(1/\sqrt{2}\right)} $$
as required.
</s>