keisoku

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 nQuotient aₙNumerator pₙDenominator qₙDecimalError
03313-0.1415926536
172273.142857140.0012644893
2153331063.14150943-8.322e-5
313551133.141592922.668e-7
4292103,99333,1023.14159265-5.779e-10
51104,34833,2153.141592653.316e-10
61208,34166,3173.14159265-1.224e-10
71312,68999,5323.141592652.914e-11
82833,719265,3813.14159265-8.715e-12
911,146,408364,9133.141592651.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.