Continued Fraction Expansion of a Real Number
Expand a real number such as π or √2 into a simple continued fraction [a0; a1, a2, …] and list each convergent with its approximation error.
Input
x=
Presets (tap to fill in)
π
e
√2
√3
Golden ratio φ
Pi approximation 22/7
log(10)
terms
Operators: + - * / ^ (power). Functions: sin cos tan asin acos atan exp log (natural log) ln log10 sqrt (√) cbrt abs pow(a, b). Constants: pi (π), e. Up to 40 terms can be expanded.
Result
Simple continued fraction of pi ≈ 3.1415926536
[3; 7, 15, 1, 292, 1, 1, 1, 2, 1]
Best rational approximation
1,146,408 / 364,913
= 3.14159265
Approximation error
1.611e-12
Approximation is slightly larger
Terms expanded
10 terms
Partial quotient a0 = 3
Convergents at each step
| Step n | Quotient aₙ | Numerator pₙ | Denominator qₙ | Decimal | Error |
|---|---|---|---|---|---|
| 0 | 3 | 3 | 1 | 3 | -0.1415926536 |
| 1 | 7 | 22 | 7 | 3.14285714 | 0.0012644893 |
| 2 | 15 | 333 | 106 | 3.14150943 | -8.322e-5 |
| 3 | 1 | 355 | 113 | 3.14159292 | 2.668e-7 |
| 4 | 292 | 103,993 | 33,102 | 3.14159265 | -5.779e-10 |
| 5 | 1 | 104,348 | 33,215 | 3.14159265 | 3.316e-10 |
| 6 | 1 | 208,341 | 66,317 | 3.14159265 | -1.224e-10 |
| 7 | 1 | 312,689 | 99,532 | 3.14159265 | 2.914e-11 |
| 8 | 2 | 833,719 | 265,381 | 3.14159265 | -8.715e-12 |
| 9 | 1 | 1,146,408 | 364,913 | 3.14159265 | 1.611e-12 |
How it works
- You can type a real number directly, or use an expression such as pi, e, sqrt(2), (1+sqrt(5))/2, or pick one of the presets.
- The tool finds each partial quotient of the simple continued fraction [a0; a1, a2, …] together with the convergent obtained up to that step.
- Convergents approach the original value while alternating above and below it, and the error shrinks as more terms are added. The best approximation is the fraction at the final step.
- The number of terms can be set between 1 and 40. For periodic continued fractions such as √2, the same partial quotient appears repeatedly.
- The error is "approximation − original value"; the smaller its absolute value, the more accurate the rational approximation.
- All calculations run entirely in your browser, and the values you enter are never sent anywhere.
Reviews
Tell us what you think of this calculator.
Write a review
Found an incorrect result or a problem? Turn this on to report it.
- Home
Continued Fraction Expansion of a Real Number