January 03, 2009

Continued Fractions

Elementary school teaches you that the friendly way to write a big improper fraction like 3/2 is as a mixed fraction, that is, "an integer plus change" like 1½. Usually discussion of mixed fractions ends there. But mathematicians know there is a lot more fun you can have with mixed fractions if you restrict all numerators to "1".

A continued fraction is a mixed fraction where the numerators of the fraction parts are always "1". The trick that makes this interesting is that you are allowed to let the denominator be another continued fraction. For example, 2/3 can be written as a continued fraction by writing the reciprocal of 1½ like this:

=

The general procedure to turn any rational number into a continued fraction is this: First, separate and write any integer part bigger than 1. Then in the denominator write the continued fraction of the reciprocal of the fractional part.

You can use the form above to try any rational number as a continued fraction. For example, try 3/5, 355/113, or 1.414.

That last one is a decimal approximation for the square root of 2. What do you think the exact continued fraction for sqrt(2) would look like?

Posted by David at January 3, 2009 10:32 AM
Comments

Beautiful, tight code. But you know tables are evil. So do it with DIVs using the DOM!

Posted by: Tom at January 15, 2009 01:05 PM
Post a comment









Remember personal info?