I was looking into this continued fraction:

$$e = 3 - \frac{1}{4 - \frac{2}{5 - \frac{3}{6 -...}}}$$

I was able to duplicate the approximations of the continued fraction with this recursive formula:
$$f(n+1) = \frac{f(n)*(n+1)*(n+2)^2*(n+1)!-1}{(n+1)*(n+2)*(n+2)!}\tag{1}$$ Where $f(0)=3$

The first few terms are:
Is there a general way to convert continued fractions into recursive formulas?
Or do these need to be dealt with on a case by case basis?

This is a reply to a comment by WA Don
Thank you for your thoughtful reply.
Which of my terms is off?

In the meantime, I'll provide a more detailed derivation.

The denominator, as a function of n, can be represented as: $$g(n)=(n+1)*(n+1)!$$ The numerator, as a recursive function of n, can be represented as: $$h(n)=(h(n-1)*(n+1)^2-1)/n$$ So we now can write the recursive approximation of e as: $$f(n)=h(n)/g(n)$$ $$=\frac{(h(n-1)*(n+1)^2-1)/n}{(n+1)*(n+1)!}$$ $$=\frac{h(n-1)*(n+1)^2-1}{n*(n+1)*(n+1)!}\tag{2}$$ Now substituting $h(n-1)=f(n-1)*g(n-1)$ into (2), we get $$f(n)=\frac{f(n-1)*g(n-1)*(n+1)^2-1}{n*(n+1)*(n+1)!}$$ $$=\frac{f(n-1)*n*n!*(n+1)^2-1}{n*(n+1)*(n+1)!}\tag{3}$$ Substituting n+1 for n in (3), we get

$$f(n+1)=\frac{f(n)*(n+1)*(n+1)!*(n+2)^2-1}{(n+1)*(n+2)*(n+2)!}\tag{4}$$ Which is just the original formula (1)

I'm still seeing an exact match between the continued fraction approximation and the recursive function in (1) or (4).

So, if there is an error in the forgoing, I'd be grateful to have it pointed out. And the specific term that deviates from the continued fraction approximation. The first few terms without removing common factors are:

  • $\begingroup$ Does this thread answer your question? $\endgroup$ Feb 8, 2021 at 6:06
  • $\begingroup$ It doesn't answer my question because all the numerators the thread are 1. In the example I used, the numerator starts at 1 and then increments by 1 at each iteration. But it's a very good thread - thank you! $\endgroup$ Feb 9, 2021 at 1:37
  • 1
    $\begingroup$ Please accept my apology. I have re-calculated your formula and I was wrong, it does indeed work. I cannot now see why I thought it did not. I'll amend the postscript. $\endgroup$
    – WA Don
    Feb 22, 2021 at 9:47

1 Answer 1


A general approach to evaluating a continued fraction is the following. Consider the fraction, \begin{align} f = q_0 + \dfrac{p_1}{q_1+\dfrac{p_2}{q_2+\dfrac{p_3}{\ddots}}} \end{align} If we define functions of $w \in \mathbb C$ by, \begin{align} t_0(w) = q_0 + w, \quad t_n(w) = \frac{p_n}{q_n +w} \end{align} then when we combine $t_0$ through $t_n$ we obtain, \begin{align} c_n(w) = t_0\circ t_1 \circ \cdots \circ t_n(w) = q_0 + \dfrac{p_1}{q_1+\dfrac{p_2}{q_2+\dfrac{\ddots}{q_{n-1}+\dfrac{p_n}{q_n+w}}}} \end{align} and we interpret $f$ to be the limit of this as $n \to \infty$ when $w=0$ (if the limit exists). The number $c_n(0)$ is called the $n$th convergent.

A useful recurrence relation exists for $c_n(w)$, $n \geqslant 0$, \begin{align} c_n(w) = \frac{P_n+P_{n-1}w}{Q_n +Q_{n-1} w} \tag{1}\label{eq1} \end{align} where we use initial conditions, $P_0 = q_0, Q_0 = 1, P_{-1} = 1, Q_{-1}=0$ and the $P_n, Q_n$ do not depend on $w$ and can be obtained from the recurrence, \begin{align} \begin{array}{l} P_{n+1} = q_{n+1}P_n + p_{n+1} P_{n-1} \\ Q_{n+1} = q_{n+1}Q_n + p_{n+1} Q_{n-1} . \end{array}\tag{2}\label{eq2} \end{align} This is proved by induction. We observe that the given initial conditions imply equation \eqref{eq1} holds when $n=0$. Then, if \eqref{eq1} holds for some $n \geqslant 0$, from the definition, \begin{align} c_{n+1}(w) &= c_n(p_{n+1}/(q_{n+1}+w)) \\ &= \frac{P_n+P_{n-1}(p_{n+1}/(q_{n+1}+w))}{Q_n+Q_{n-1}(p_{n+1}/(q_{n+1}+w))} \\ &=\frac{P_{n}q_{n+1}+P_n w + P_{n-1}p_{n+1}}{Q_{n}q_{n+1}+Q_n w + Q_{n-1}p_{n+1}} \\ &=\frac{P_{n+1}+P_n w}{Q_{n+1}+Q_n w}. \end{align} Thus \eqref{eq1} also holds for $n+1$ with the new coefficients $P_{n+1}, Q_{n+1}$ given by \eqref{eq2}.

Postscipt: After a false start (apologies) the methodology described in this answer delivers the same recurrence as in the OP question, $f_{n+1}=\frac{f_n(n+1)(n+2)^2(n+1)!-1}{(n+1)(n+2)(n+2)!}$, which generates the same fractions, $\frac{3}{1}, \frac{11}{4}, \frac{49}{18}, \frac{261}{96}, \cdots$.

The general formula presented here can be used to evaluate any continued fraction. But it consists of a ratio of two second order recurrence formulae. I doubt it can always be simplified to a single first order recurrence, as it can in this example.

  • $\begingroup$ WA Don, I updated my original post to help find the discrepancy you suggested. $\endgroup$ Feb 21, 2021 at 20:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .