A Continued Fraction for Error Function by Ramanujan

4 comments
Today's post is inspired by this question I asked sometime back on MSE. And after some effort (offering a bounty) I received a very good answer from a user on MSE. This question was asked for the first time by Ramanujan in the "Journal of Indian Mathematical Society" 6th issue as Question no. 541, page 79 in the following manner:

Prove that $$\left(1 + \frac{1}{1\cdot 3} + \frac{1}{1\cdot 3\cdot 5} + \cdots\right) + \left(\cfrac{1}{1+}\cfrac{1}{1+}\cfrac{2}{1+}\cfrac{3}{1+}\cfrac{4}{1+\cdots}\right) = \sqrt{\frac{\pi e}{2}}\tag{1}$$ It turns out that the first series is intimately connected with the error function given $$\operatorname{erf}(x) = \frac{2}{\sqrt{\pi}}\int_{0}^x e^{-t^2}\,dt\tag{2}$$ In his famous letter to G. H. Hardy, dated 16th January 1913, Ramanujan gave the following continued fraction for the integral used in the definition of error function given above: $$\int_{0}^{a}e^{-x^{2}}\,dx = \frac{\sqrt{\pi}}{2} - \cfrac{e^{-a^{2}}}{2a+}\cfrac{1}{a+}\cfrac{2}{2a+}\cfrac{3}{a+}\cfrac{4}{2a+\cdots}\tag{3}$$ In this post we will establish the relations $(1)$ and $(3)$ along the lines indicated in the answer on MSE.

Summing the Given Series

We first start with summing the given series $$S = 1 + \frac{1}{1\cdot 3} + \frac{1}{1\cdot 3\cdot 5} + \cdots$$ Clearly if we define a function $f(x)$ by $$f(x) = x + \frac{x^{3}}{1\cdot 3} + \frac{x^{5}}{1\cdot 3\cdot 5} + \cdots\tag{4}$$ then $S = f(1)$. It turns out that if we differentiate the series for $f(x)$ term by term then we obtain \begin{align} f'(x) &= 1 + x^{2} + \frac{x^{4}}{1\cdot 3} + \frac{x^{6}}{1\cdot 3\cdot 5} + \cdots\notag\\ &= 1 + x\left(x + \frac{x^{3}}{1\cdot 3} + \frac{x^{5}}{1\cdot 3\cdot 5} + \cdots\right)\notag\\ &= 1 + xf(x)\notag \end{align} so that the function $y = f(x)$ satisfies the following first order differential equation $$\frac{dy}{dx} - xy = 1, y(0) = 0$$ Clearly the integrating factor here $e^{-x^{2}/2}$ and hence we have $$y = f(x) = e^{x^{2}/2}\int_{0}^{x}e^{-t^{2}/2}\,dt$$ and hence $$S = f(1) = \sqrt{e}\int_{0}^{1}e^{-t^{2}/2}\,dt$$ We can rewrite the sum $S$ in the following manner \begin{align} S &= \sqrt{e}\int_{0}^{1}e^{-t^{2}/2}\,dt\notag\\ &= \sqrt{e}\int_{0}^{\infty}e^{-t^{2}/2}\,dt - \sqrt{e}\int_{1}^{\infty}e^{-t^{2}/2}\,dt\notag\\ &= \sqrt{\frac{\pi e}{2}} - \sqrt{e}\int_{1}^{\infty}e^{-t^{2}/2}\,dt\notag \end{align} where the first integral is easily calculated from the famous integral $$\int_{0}^{\infty}e^{-t^{2}}\,dt = \frac{\sqrt{\pi}}{2}\tag{5}$$ It follows that the equation $(1)$ can be established if we show that $$\sqrt{e}\int_{1}^{\infty}e^{-t^{2}/2}\,dt = \cfrac{1}{1+}\cfrac{1}{1+}\cfrac{2}{1+}\cfrac{3}{1+}\cfrac{4}{1+\cdots}\tag{6}$$ It turns out that it is much easier to consider the function $$\phi(x) = e^{x^{2}/2}\int_{x}^{\infty}e^{-t^{2}/2}\,dt\tag{7}$$ and derive a continued fraction for $\phi(x)$ and then put $x = 1$ to get $(6)$.

Derivatives of $\phi(x)$

If we differentiate $\phi(x)$ we obtain $$\phi'(x) = xe^{x^{2}/2}\int_{x}^{\infty}e^{-t^{2}/2}\,dt - e^{x^{2}/2}\cdot e^{-x^{2}/2} = x\phi(x) - 1\tag{8}$$ and a further differentiation gives $$\phi''(x) = \phi(x) + x\phi'(x) = \phi(x) + x(x\phi(x) - 1) = (1 + x^{2})\phi(x) - x$$ It is now easy to guess the pattern of $n^{\text{th}}$ derivative of $\phi(x)$ and we have $$\phi^{(n)}(x) = P_{n}(x)\phi(x) - Q_{n}(x)\tag{9}$$ where $P_{n}(x), Q_{n}(x)$ are polynomials. We will derive many properties of these polynomials starting with the following $$\boxed{\begin{align}P_{n + 1}(x) &= xP_{n}(x) + P_{n}'(x)\notag\\ Q_{n + 1}(x) &= P_{n}(x) + Q_{n}'(x)\notag\end{align}}\tag{10}$$ Clearly we can see that \begin{align} P_{n + 1}(x)\phi(x) - Q_{n + 1}(x) &= \phi^{(n + 1)}(x) = \{\phi^{(n)}(x)\}'\notag\\ &= \{P_{n}(x)\phi(x) - Q_{n}(x)\}'\notag\\ &= P_{n}(x)\phi'(x) + P_{n}'(x)\phi(x) - Q_{n}'(x)\notag\\ &= P_{n}(x)\{x\phi(x) - 1\} + P_{n}'(x)\phi(x) - Q_{n}'(x)\notag\\ &= \{xP_{n}(x) + P_{n}'(x)\}\phi(x) - \{P_{n}(x) + Q_{n}'(x)\}\notag \end{align} and we get the equations $(9)$ by comparing the LHS and RHS of the above equation.

The initial values of these polynomials are $P_{0}(x) = 1, P_{1}(x) = x$ and $Q_{0}(x) = 0, Q_{1}(x) = 1$. Differentiating the fundamental relation $\phi'(x) = x\phi(x) - 1$ $n$ times using Leibniz rule we get the following relation $$\phi^{(n + 1)}(x) = x\phi^{(n)}(x) + n\phi^{(n - 1)}(x)$$ if $n \geq 1$ and therefore we get \begin{align} P_{n + 1}(x)\phi(x) - Q_{n + 1}(x) &= x\{P_{n}(x)\phi(x) - Q_{n}(x)\} + n\{P_{n - 1}(x)\phi(x) - Q_{n - 1}(x)\}\notag\\ &= \{xP_{n}(x) + nP_{n - 1}(x)\}\phi(x) - \{xQ_{n}(x) + nQ_{n - 1}(x)\}\notag \end{align} and thus by comparing LHS and RHS we get $$P_{n + 1}(x) = xP_{n}(x) + nP_{n - 1}(x),\, Q_{n + 1}(x) = xQ_{n}(x) + nQ_{n - 1}(x)$$ Comparing the above recursive relation of $P_{n}(x)$ with the previous one given in equation $(10)$ we also get $P_{n}'(x) = nP_{n - 1}(x)$. We summarize our results as follows $$\boxed{\begin{align} P_{0}(x) &= 1,\, P_{1}(x) = x\notag\\ Q_{0}(x) &= 0,\, Q_{1}(x) = 1\notag\\ P_{n + 1}(x) &= xP_{n}(x) + nP_{n - 1}(x),\, n\geq 1\notag\\ Q_{n + 1}(x) &= xQ_{n}(x) + nQ_{n - 1}(x),\, n\geq 1\notag\\ P_{n}'(x) &= nP_{n - 1}(x),\,n\geq 1\notag \end{align}}\tag{11}$$ Next we establish the following identity which seems like a cross multiplication of $P$ and $Q$ $$Q_{n + 1}(x)P_{n}(x) - P_{n + 1}(x)Q_{n}(x) = (-1)^{n} n!\tag{12}$$ Clearly by direct substitution it holds for $n = 0, 1$ and we can try induction on $n$ to prove it for all $n$. We assume that the equation $(12)$ above holds for $n = m$ and try to prove it for $n = m + 1$. We have \begin{align} F(x) &= Q_{m + 2}(x)P_{m + 1}(x) - P_{m + 2}(x)Q_{m + 1}(x)\notag\\ &= \{xQ_{m + 1}(x) + (m + 1)Q_{m}(x)\}P_{m + 1}(x) - \{xP_{m + 1}(x) + (m + 1)P_{m}(x)\}Q_{m + 1}(x)\notag\\ &= - (m + 1)\{Q_{m + 1}(x)P_{m}(x) - P_{m + 1}(x)Q_{m}(x)\}\notag\\ &= - (m + 1)(-1)^{m}m! = (-1)^{m + 1}(m + 1)!\notag \end{align} and therefore the relation holds for $n = m + 1$ and hence by induction equation $(12)$ holds for all values of $n$.

Next another identity concerning sign of $\phi^{(n)}(x)$ is needed. We have $$(-1)^{n}\phi^{(n)}(x) > 0,\, n \geq 0\tag{13}$$ for all $x$. We have \begin{align} \int_{0}^{\infty}e^{-tx}e^{-t^{2}/2}\,dt &= e^{x^{2}/2}\int_{0}^{\infty}e^{-(x + t)^{2}/2}\,dt\notag\\ &= e^{x^{2}/2}\int_{x}^{\infty}e^{-z^{2}/2}\,dz\text{ (by putting }z = x + t)\notag\\ &= \phi(x)\notag \end{align} and hence $$\phi^{(n)}(x) = (-1)^{n}\int_{0}^{\infty}t^{n}e^{-tx}e^{-t^{2}/2}\,dt$$ and the relation $(13)$ is now obvious.

Series Expansion for $P_{n}(x)$

We will now focus more on the polynomial $P_{n}(x)$. It turns out that we have $$P_{n}(x) = e^{-x^{2}/2}\frac{d^{n}}{dx^{n}}\{e^{x^{2}/2}\}\tag{14}$$ Clearly if we let $a_{n}(x) = e^{-x^{2}/2}\{e^{x^{2}/2}\}^{(n)}$ then $a_{0}(x) = 1$ and $a_{1}(x) = x$. Also we have \begin{align} a_{n + 1}(x) &= e^{-x^{2}/2}\{e^{x^{2}/2}\}^{(n + 1)}\notag\\ &= e^{-x^{2}/2}\{xe^{x^{2}/2}\}^{(n)}\notag\\ &= x\left(e^{-x^{2}/2}\{e^{x^{2}/2}\}^{(n)}\right) + ne^{-x^{2}/2}\{e^{x^{2}/2}\}^{(n - 1)}\notag\\ &= xa_{n}(x) + na_{n - 1}(x)\notag \end{align} so that $a_{n}(x)$ satisfies the same recurrence relation $(11)$ as $P_{n}(x)$. At the same time the initial values of $a_{n}(x)$ for $n = 0, 1$ also match with those of $P_{n}(x)$ and hence $a_{n}(x) = P_{n}(x)$ for all $x$ and $n$.

Next we start with the famous integral $$\frac{\sqrt{\pi}}{2} = \int_{0}^{\infty}e^{-x^{2}}\,dx$$ and put $z = x\sqrt{2}$ to get $$\sqrt{\frac{\pi}{2}} = \int_{0}^{\infty}e^{-z^{2}/2}\,dz = \frac{1}{2}\int_{-\infty}^{\infty}e^{-z^{2}/2}\,dz$$ Putting $z = t - x$ we get $$\sqrt{2\pi} = e^{-x^{2}/2}\int_{-\infty}^{\infty}e^{tx}e^{-t^{2}/2}\,dt$$ and therefore we have $$e^{x^{2}/2} = \frac{1}{\sqrt{2\pi}}\int_{-\infty}^{\infty}e^{tx}e^{-t^{2}/2}\,dt$$ and differentiating this relation $n$ times with respect to $x$ we get \begin{align} P_{n}(x)\,&= \frac{e^{-x^{2}/2}}{\sqrt{2\pi}}\int_{-\infty}^{\infty}t^{n}e^{tx}e^{-t^{2}/2}\,dt\notag\\ &= \frac{1}{\sqrt{2\pi}}\int_{-\infty}^{\infty}t^{n}e^{-(t - x)^{2}/2}\,dt\notag\\ &= \frac{1}{\sqrt{2\pi}}\int_{-\infty}^{\infty}(u + x)^{n}e^{-u^{2}/2}\,du\notag\\ &= \sum_{k = 0}^{n}\binom{n}{k}x^{n - k}\left(\frac{1}{\sqrt{2\pi}}\int_{-\infty}^{\infty}u^{k}e^{-u^{2}/2}\,du\right)\notag\\ &= \sum_{0 \leq 2k \leq n}\binom{n}{2k}x^{n - 2k}\left(\frac{1}{\sqrt{2\pi}}\int_{-\infty}^{\infty}u^{2k}e^{-u^{2}/2}\,du\right)\notag\\ &= \sum_{0 \leq 2k \leq n}\binom{n}{2k}x^{n - 2k}\left(\frac{2}{\sqrt{2\pi}}\int_{0}^{\infty}u^{2k}e^{-u^{2}/2}\,du\right)\notag\\ &= \sum_{0 \leq 2k \leq n}\binom{n}{2k}x^{n - 2k}\left(\frac{2^{k}}{\sqrt{\pi}}\int_{0}^{\infty}t^{k - 1/2}e^{-t}\,dt\right)\text{ (by putting }u^{2} = 2t)\notag\\ &= \sum_{0 \leq 2k \leq n}\binom{n}{2k}x^{n - 2k}\cdot\dfrac{2^{k}\Gamma\left(k + \dfrac{1}{2}\right)}{\sqrt{\pi}}\notag\\ &= \sum_{0 \leq 2k \leq n}\binom{n}{2k}x^{n - 2k}\cdot\dfrac{(2k)!}{2^{k}k!}\notag \end{align} and we thus obtain the series for $P_{n}(x)$ given by $$P_{n}(x) = \sum_{0 \leq 2k \leq n}\binom{n}{2k}\frac{(2k)!}{2^{k}k!}x^{n - 2k}\tag{15}$$ It follows that $P_{n}(x)$ is even function if $n$ is even and is an odd function if $n$ is odd. Also using the greatest $k$ such that $2k\leq n$ in the above series we see that $$P_{2n}(x) \geq \frac{(2n)!}{2^{n}n!},\,\frac{P_{2n + 1}(x)}{x}\geq \frac{(2n + 1)!}{2^{n}n!}\tag{16}$$ for all $x$.

Continued Fraction for $\phi(x)$

From $(13)$ we see that $\phi^{(2n)}(x) > 0$ for all $n$ and $x$ and hence noting that $P_{2n}(x) > 0$ for all $x$ (from $(16)$) we get $$\frac{Q_{2n}(x)}{P_{2n}(x)} < \phi(x)$$ for all $x$ and non-negative integers $n$. Similarly for $x > 0$ we see that $\phi^{(2n + 1)}(x) < 0$ and therefore $$\phi(x) < \frac{Q_{2n + 1}(x)}{P_{2n + 1}(x)}$$ for non-negative integers $n$.

It follows that if $x > 0$ and $n$ is a non-negative integer then $$\frac{Q_{2n}(x)}{P_{2n}(x)} < \phi(x)< \frac{Q_{2n + 1}(x)}{P_{2n + 1}(x)},\, \frac{Q_{2n + 2}(x)}{P_{2n + 2}(x)} < \phi(x)< \frac{Q_{2n + 1}(x)}{P_{2n + 1}(x)}\tag{17}$$ and this leads to $$0 < \phi(x) - \frac{Q_{2n}(x)}{P_{2n}(x)} < \frac{Q_{2n + 1}(x)}{P_{2n + 1}(x)} - \frac{Q_{2n}(x)}{P_{2n}(x)} = \frac{(2n)!}{P_{2n}(x)P_{2n + 1}(x)}$$ and $$0 < \frac{Q_{2n + 1}(x)}{P_{2n + 1}(x)} - \phi(x) < \frac{Q_{2n + 1}(x)}{P_{2n + 1}(x)} - \frac{Q_{2n + 2}(x)}{P_{2n + 2}(x)} = \frac{(2n + 1)!}{P_{2n + 1}(x)P_{2n + 2}(x)}$$ by using the relation $(12)$. We can combine the above inequalities and write $$0 < \left|\phi(x) - \frac{Q_{n}(x)}{P_{n}(x)}\right| < \frac{n!}{P_{n}(x)P_{n + 1}(x)}\tag{18}$$ for all $x > 0$ and all non-negative integers $n$. Using the estimates for $P_{n}(x)$ given in $(16)$ we see that $$\lim_{n \to \infty}\frac{Q_{n}(x)}{P_{n}(x)} = \phi(x)\tag{19}$$ for all $x > 0$.

From the recurrence relations $(11)$ it is now clear that $Q_{n}(x)/P_{n}(x)$ is the $n^{\text{th}}$ convergent of the continued fraction $$\cfrac{1}{x + }\cfrac{1}{x + }\cfrac{2}{x + }\cfrac{3}{x + }\cfrac{4}{x + \cdots}$$ and from $(19)$ it follows that these convergents do converge to $\phi(x)$ if $x > 0$. It follows that $$\phi(x) = e^{x^{2}/2}\int_{x}^{\infty}e^{-t^{2}/2}\,dt = \cfrac{1}{x + }\cfrac{1}{x + }\cfrac{2}{x + }\cfrac{3}{x + }\cfrac{4}{x + \cdots}\tag{20}$$ for positive values of $x$. Putting $x = 1$ we get equation $(6)$ and thus the problem posed by Ramanujan in equation $(1)$ is solved. The continued fraction in equation $(3)$ is equivalent to $$e^{a^{2}}\int_{a}^{\infty}e^{-t^{2}}\,dt = \cfrac{1}{2a + }\cfrac{1}{a + }\cfrac{2}{2a + }\cfrac{3}{a + }\cfrac{4}{2a + \cdots}$$ and it can be proved in the manner similar to the continued fraction of $\phi(x)$. We only need to note that if $$\psi(x) = e^{x^{2}}\int_{x}^{\infty}e^{-t^{2}}\,dt
$$ then $\psi'(x) = 2x\psi(x) - 1$ so that the polynomials $P_{n}(x), Q_{n}(x)$ corresponding to $\psi^{(n)}(x) = P_{n}(x)\psi(x) - Q_{n}(x)$ will have the following recurrence relations $$\boxed{\begin{align} P_{0}(x) &= 1,\, P_{1}(x) = 2x\notag\\ Q_{0}(x) &= 0,\, Q_{1}(x) = 1\notag\\ P_{n + 1}(x) &= 2xP_{n}(x) + 2nP_{n - 1}(x)\notag\\ Q_{n + 1}(x) &= 2xQ_{n}(x) + 2nQ_{n - 1}(x)\notag \end{align}}\tag{21}$$ and like the case of $\phi(x)$ these recurrence relations lead to the continued fraction $$\psi(x) = e^{x^{2}}\int_{x}^{\infty}e^{-t^{2}}\,dt = \cfrac{1}{2x +}\cfrac{2}{2x +}\cfrac{4}{2x +}\cfrac{6}{2x +}\cfrac{8}{2x + \cdots}$$ and it can be easily simplified by cancelling $2$ from numerator and denominator at appropriate terms in the continued fraction to get the final version as mentioned by Ramanujan $$\psi(x) = e^{x^{2}}\int_{x}^{\infty}e^{-t^{2}}\,dt = \cfrac{1}{2x +}\cfrac{1}{x +}\cfrac{2}{2x +}\cfrac{3}{x +}\cfrac{4}{2x + \cdots}\tag{22}$$
Note: Some of the proofs are taken from an online paper by Omran Kouba (who provided an answer to my question posted on MSE).

Print/PDF Version

4 comments :: A Continued Fraction for Error Function by Ramanujan

Post a Comment

  1. The substitution by u^2 = 2t^2 is wrong, it has to be u^2 = 2t.

    My main question is though: I don't understand the conclusions in (16), what do you mean by these?

  2. @excentrique,
    You are right and thanks for catching the typo. I will fix it. Equation $(16)$ comes from $(15)$ and we are just using the fact that $P_{n}(x)$ is greater than one particular term in the series representation $(15)$ of $P_{n}(x)$ and this we do based on parity of $n$. This is possible because each term in series for $P_{2n}(x)$ and for $P_{2n + 1}(x)/x$ is positive.

    Regards,
    Paramanand

  3. Hi Paramanand,

    thanks for the explanation.
    I worked my way through the proof and I'm almost there at the end where I cannot quite reproduce the proof for psi(x), the recurrence relations of (21) don't lead to the conclusion (12), so how can I proceed from these relations to a similar proof of phi(x). Is there a shorter way to explain oneself that the continued fraction in (3) is equivalent to the new one at the end?

  4. @excentrique,

    From equation $(21)$ you will get an equation similar to $(12)$ namely $$Q_{n + 1}(x)P_{n}(x) - P_{n + 1}(x)Q_{n}(x) = (-2)^{n}n!$$ and there will some minor tweaks in the equations which follow accordingly. But end result will be as mentioned after equation $(21)$. You should try out these calculations and let me know if you face any problem.

    Regards,
    Paramanand