Approximations with continued fractions

In an excellent blog post earlier this year, Dave Richeson commented on the approximation:

sin(11)approx -1.

The reason for this is the well-known approximation

displaystyle{piapprox frac{22}{7}}

from which

sin(11)approx sinleft(frac{7pi}{2}right)=-1.

And this approximation, and more, can be obtained from the continued fraction for pi. This raises the question: can other interesting approximations be obtained from other continued fractions? Before we start, here’s the beginning of the continued fraction for pi:


Since 292 is a fairly large number, we would expect a good approximation if we chopped the continued fraction at this point:


We can do this easily in Sage:

sage: F=continued_fraction(pi)
sage: F
  [3, 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 3]
sage: i=list(F).index(max(F))
sage: convergent(F,i-1)

So here’s a recipe for finding interesting approximations: find a continued fraction containing a large integer, and take the convergent up to that value.

Here are some examples, first a “near integer” e^{1535/483}approx 24:

sage: F=continued_fraction(log(24))
sage: F
  [3, 5, 1, 1, 1, 1, 1, 1, 6, 35660, 1, 3]
sage: i=list(F).index(max(F))
sage: convergent(F,i-1)
sage: exp(1535/483).n()

Next, an approximation to pi (this one is actually quite well known) piapprox (2143/22)^{1/4}:

sage: F=continued_fraction(pi^4)
sage: F
  [97, 2, 2, 3, 1, 16539, 1, 6, 3]
sage: i=list(F).index(max(F))
sage: convergent(F,i-1)
sage: (2143/22)^(1/4).n()

And an approximation to the Euler-Mascheroni constant gammaapprox (721/949)^2:

sage: F=continued_fraction(sqrt(euler_gamma))
sage: F
  [0, 1, 3, 6, 6, 5, 1, 301, 2, 24, 3, 1]
sage: i=list(F).index(max(F))
sage: x=convergent(F,i-1);x
sage: x^2.n()
sage: euler_gamma().n()

To read more about continued fractions, the Wikipedia page is a good start, and there’s lots of detail here (including some discussion about approximations). For those of you with access to a good library, William Stein’s superb book “Elementary Number Theory: Primes, Congruences, and Secrets” has a chapter on continued fractions.

2 thoughts on “Approximations with continued fractions

  1. Marvellous blog!

    A tiny slip of the finger at “chopped the continued fraction at this point: . . . 335/113”

    Sage got it right (of course):

    sage: convergent(F,i-1)

    I noticed only because 11 3|3 55 (| means “divides”) is a well-known and easily remembered approximation for small, four-function calculators. It was especially useful eons ago, at the dawn of the calculator age (think Bomar), when four-function meant just and only four functions with eight or fewer significant digits.

    Off-topic aside: I enjoy your music for the end of the week.


Leave a Reply

Your email address will not be published. Required fields are marked *