Continued Fraction
calculator.
Turn π, a fraction or a square root into nested whole-number fractions.
- Terms shown
- 12
- Repeating block
- None
- Convergent 3
- 355113
The term 292 is large, so the convergent just before it, 355 over 113, is unusually close for its small denominator.
How close each convergent gets
Drag along to pick a convergentConvergent 3 is 355 over 113, within 1 over 3,740,526 of the number. Across all 11 bounded convergents the guarantee rises to about 12.4 decimal digits.
Best fraction with a small denominator
Convergent 3 is the closest with a denominator up to 1,000. It is off by about 2.7 × 10⁻⁷.
Convergents
| k | Term | Convergent | Decimal | Side |
|---|---|---|---|---|
| 0term 3 | 3 | 3 | 3Side Below | Below |
| 1term 7 | 7 | 227 | 3.142857143Side Above | Above |
| 2term 15 | 15 | 333106 | 3.141509434Side Below | Below |
| 3term 1 | 1 | 355113 | 3.14159292Side Above | Above |
| 4term 292 | 292 | 103,99333,102 | 3.141592653Side Below | Below |
| 5term 1 | 1 | 104,34833,215 | 3.141592654Side Above | Above |
| 6term 1 | 1 | 208,34166,317 | 3.141592653Side Below | Below |
| 7term 1 | 1 | 312,68999,532 | 3.141592654Side Above | Above |
Working
- 1Start from the published terms (OEIS A001203)[3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, …]
- 2Each convergent: p = a × p before + p two before, and the same for qk = 0:3 × 1 + 03 × 0 + 1=3k = 1:7 × 3 + 17 × 1 + 0=227k = 2:15 × 22 + 315 × 7 + 1=333106k = 3:1 × 333 + 221 × 106 + 7=355113
- 3Check: neighboring convergents cross-multiply to differ by exactly 1355 × 106 − 333 × 113= 37,630 − 37,629 = 1
How it's worked out
A simple continued fraction writes a number as a whole part, plus 1 over a whole number, plus 1 over another, and so on. The whole numbers are the terms, also called partial quotients. A short way to write them is a list with a semicolon after the first one.
For a fraction, the terms are the quotients of the Euclidean algorithm. You divide, then divide the old divisor by the remainder, and stop when the remainder is 0. For 415 over 93 that takes 4 divisions and gives [4; 2, 6, 7]. A rational number always ends, because the remainders keep shrinking.
| Division | Term |
|---|---|
| 415 = 4 × 93 + 43 | 4 |
| 93 = 2 × 43 + 7 | 2 |
| 43 = 6 × 7 + 1 | 6 |
| 7 = 7 × 1 | 7 |
Cut the list after any term and you get a convergent, which is an ordinary fraction. You do not have to rebuild the nest each time. Each new top and bottom comes from the two before it, starting from 1 over 0 and the first term over 1.
Dummit's course notes prove two facts the tool relies on. The convergents land on alternate sides of the number, first below, then above. And the error of each one is at most 1 over the product of its own bottom and the next bottom. That bound is how the tool can promise digits for π without knowing π exactly.
A square root of a whole number that is not a perfect square never ends, but its terms repeat. The tool finds them with whole numbers only, so no rounding creeps in. The block always ends with twice the first term, as the table shows.
| Root | Terms | Block |
|---|---|---|
| √2 | [1; 2, …] | 1 |
| √3 | [1; 1, 2, …] | 2 |
| √5 | [2; 4, …] | 1 |
| √6 | [2; 2, 4, …] | 2 |
| √7 | [2; 1, 1, 1, 4, …] | 4 |
| √8 | [2; 1, 4, …] | 2 |
| √10 | [3; 6, …] | 1 |
| √11 | [3; 3, 6, …] | 2 |
| √12 | [3; 2, 6, …] | 2 |
| √13 | [3; 1, 1, 1, 1, 6, …] | 5 |
| √14 | [3; 1, 2, 1, 6, …] | 4 |
| √15 | [3; 1, 6, …] | 2 |
Worked examples
Mei asks why 355 over 113 is so close to π
Mei knows 22 over 7 from school and has seen 355 over 113 quoted as far better. The terms of π begin [3; 7, 15, 1, 292, 1, …], taken from OEIS A001203. The first four convergents are below.
The next term is 292, which is huge. A big next term makes the next bottom huge too, so the bound for 355 over 113 is 1 over 3,740,526. The real gap is about 2.67 × 10⁻⁷, so it matches π to 6 decimal places.
No fraction with a bottom of 1,000 or less does better: the tool's limit finds 355 over 113 again. With the limit set to 100, the best is 311 over 99, a fraction that sits between two convergents.
Ravi wants a ratio near 415 to 93 with small numbers
Ravi needs a gear pair close to 415 to 93, and his smaller gear can have at most 20 teeth. The terms are [4; 2, 6, 7], so the convergents are 4 over 1, 9 over 2, 58 over 13, 415 over 93. The last one is the ratio itself.
With a limit of 20 on the bottom, the closest is 58 over 13, about 4.46154. The true ratio is about 4.46237, so a 58 to 13 pair is off by about 0.0008.
Sofia solves x² − 19y² = 1
Sofia's number theory homework asks for the smallest whole numbers with x² − 19y² = 1, a Pell equation. The terms of √19 are [4; 2, 1, 3, 1, 2, 8, …], with a block of 6 that repeats.
MathWorld's rule says: when the block has an even length, take the convergent just before its end. That is convergent 5, which is 170 over 39.
Reading your result
A large term means a good fraction. The convergent just before a big term is unusually close for its size. In the terms of e, the large terms come in a steady pattern, [2; 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, …], so e has no single standout fraction.
All ones is the slowest case. The golden ratio has every term equal to 1. Its convergents, 1 over 1, 2 over 1, 3 over 2, 5 over 3, 8 over 5, 13 over 8, 21 over 13, 34 over 21, are ratios of Fibonacci numbers, and their bottoms grow as slowly as bottoms can.
A typed decimal is a fraction. Typing 3.14159 gives [3; 7, 15, 1, 25, 1, 7, 4], which ends, because 3.14159 is exactly 314,159 over 100,000. Its first four terms agree with π and then it goes its own way. Pick π from the constants to see its real terms.
Two endings name one number. [3; 7, 16] and [3; 7, 15, 1] both equal 355 over 113, since a last term can always split into one less, then 1. The tool shows the shorter form when it expands a number.
Negative numbers start below. The first term is rounded down, so −7 over 3 starts at −3 and reads [−3; 1, 2]. Every term after the first stays positive.
Common mistakes
- Expanding a rounded decimal. √2 is [1; 2, 2, 2, …] with 2s for ever, but 1.41421356 breaks the pattern at term 11. Use the square root option, which never rounds.
- Taking the wrong end of the block for Pell. √13 has a block of 5, an odd length. Its convergent 18 over 5 gives 324 − 325 = −1, not 1, so you need the end of the second block, 649 over 180.
- Expecting each convergent to be below the number. They take turns. Convergent 0 is below, convergent 1 is above, and the number always sits between two neighbors.
- Forgetting the whole part. The first term is the whole part, and it can be 0. So 0.75 is [0; 1, 3], not a list that starts with 1.
Questions people ask
Sources
- David S. Dummit, Math 4527 Number Theory 2, lecture 4: continued fractions, Northeastern University, 2021
- Eric W. Weisstein, Pell Equation, MathWorld
- Eric W. Weisstein, Convergent, MathWorld
- OEIS A001203: simple continued fraction expansion of π
- OEIS A003417: continued fraction for e
- Python documentation, fractions module, Fraction.limit_denominator