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
Presets (tap to fill in)
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.
Related calculators
Function Graph Plotter f(x)
NumericalType an expression such as sin(x) or x^2-2 and instantly plot its graph over a chosen x range. Maximum, minimum, zeros, and sample point values are shown alongside.
Open calculator →Graph Two Functions f(x) and g(x)
NumericalPlot two expressions f(x) and g(x) on the same axes in distinct colors, and automatically find their max, min, and intersection points.
Open calculator →Data Point f(x) Graph Plotter
NumericalJust paste your (x, y) data points to instantly draw a line-and-point chart. See the point count plus the minimum, maximum, and average of y at the same time.
Open calculator →Plot Data Points f(x), g(x)
NumericalPaste two sets of (x, y) data points and get f(x) and g(x) drawn as color-coded overlaid line graphs, with each series' point count and min/max.
Open calculator →