]> Continued Fractions - Converting to Decimal

Converting to Decimal

Suppose we want to output a decimal representation of α=[a 1 ;a 2 ,...]. Then we start computing convergents via a table with one change: when the last two convergents have the same integer part n, we output and subtract n, then multiply the numerator by 10. We demonstrate this on π, using the space-saving "/"-notation.

3 7 15 1 292 ... 0 /1 1 /0 3 /1 22 /7

The last two convergents both floor to 3, so we output 3, subtract it from both convergents to get 0 /1 ,1 /7 , and multiply by 10:

Output: 3 ....

3 7 15 1 292 ... 0 /1 1 /0 0 /1 10 /7

We've deleted the old values for clarity, but in future we shall preserve them. Continuing for a few more steps:

Output: 3.141 ...

3 7 15 1 292 ... 0 /1 1 /0 0 /1 10 /7,30 /7,20 /7 150 /106,440 /106,160 /106 180 /113

Conversion From Decimal

Converting to a nonsimple continued fraction is immediate, as seen by the example of π:

π = 3 +1 0 +10 1 +1 0 +10 4 +... = 3 +1 0 +1000 141 +1 0 +1000 592 +...