The fraction is a good approximation to the irrational number : so much so that it is celebrated in Pi Approximation Day on 22 July. But have you ever wondered how to calculate rational approximations to irrational numbers?

The answer comes from *continued fractions*: these are a nested series of fractions that can reveal hidden properties of numbers. Any number can be written as a continued fraction. Rational numbers (including integers) can be written as finite continued fractions: for example

*good*approximation of an irrational number if there isn't a fraction that is closer to with a smaller denominator . And the continued fraction expansion of an irrational number gives the best series of approximations in this sense, for an irrational number.

The first few approximations of produced in this way:

very quickly get close to the true value of . Their differences from are approximately:

If you count the curves of seeds spiralling in a sunflower you'll find pairs (counting spirals curving left and curving right) that are (almost always) neighbours in the Fibonacci series, all approximations of . | ||

But not all approximations work so well for irrational numbers. For example, the approximations from the continued fraction of (the limit of the ratio of successive Fibonacci numbers – you can read more here) are:

*badly approximable*. You can tell something is badly approximable if the numbers in its continued fraction are bounded (they don't ever exceed some fixed number) and this is a measure of how irrational they are. In fact, is the most irrational number, with the numbers in its continued fraction never exceeding 1:

*golden ratio*. The continued fractions of other irrational numbers, such as , also reveal hidden patterns:

You can read more about continued fractions in John D Barrow's article, Chaos in Numberland: The secret life of continued fractions.

## Comments

## Continued fractions

Use a matrix to evaluate successive partial values of for phi:

[[0 1],[1 1]]

or root 2:

[[0 1],[1 2]]

or root N:

[[0 (N-(n'*n'))],[0 2n']] (where root n' is the nearest perfect square less than N)

Note that the first row vector of this matrix takes the second entry of the previous result and moves it up to the first entry of the new result (and scales it by a 'factor' measuring the difference from the nearest square in the case general square root). This gives a fraction a/b in the form of the output vector [a b] that, added to n' approximates a square root by an improper fraction, n' + (a/b)

This adapts the method of pure partial fractions. See wikipedia article https://en.wikipedia.org/wiki/Continued_fraction#Generalized_continued_… for the motivation.

## Continued Phractions

I entered Rachel's continued fraction for Phi as 1+(1/(1+(1/(1+(1/(1+(1/(1+(1/(1+(1/(1+1)))))))))))) into Wolfram Alpha and got the fraction 34/21, two successive Fibonacci numbers, which I found very satisfying and exciting. Rachel's formulation had 13 "1"s, and 13 is the number before 21 in Fibonacci. The 13th "1" right at the bottom of Rachel's continued fraction pile has a plus sign and three dots after it, but to make my formulation suitable for Wolfram I put another "1" after that last plus sign instead, to seal it as it were rather than leave it open.

Anyway, I'm very interested in sequences similar to Fibonacci, especially for their potential to model natural structures and processes at least as well as Fibonacci's does, including those which differ minimally from the Fibonacci recurrence formula a(n) = a(n-1) + a(n-2). There's one known as Narayana's cows (OEIS A000930) whose recurrence has a "3" at the end instead of a "2", that is a(n) = a(n-1) + a(n-3) and has a ratio constant of roughly 1.4656, which I call the Bovine ratio, symbolised by the Greek(ish) letter Moo. Can anyone formulate the continued fraction for that ratio as Rachel did for Phi?