Connect via MCP →

Enter Calculation

Formula

Advertisement

Results

Continued fraction value f
3.1415926535898
last convergent f_n (n = number of terms)
n Convergent f_n
0 4.0
1 3.0
2 3.1666666666667
3 3.1372549019608
4 3.1423423423423
5 3.1414634146341
6 3.1416149068323
7 3.1415888250921
8 3.1415933118799
9 3.1415925404465
10 3.1415926730303
11 3.1415926502502
12 3.1415926541634
13 3.1415926534913
14 3.1415926536067
15 3.1415926535869
16 3.1415926535903
17 3.1415926535897
18 3.1415926535898
19 3.1415926535898
20 3.1415926535898

What this calculator does

This tool evaluates a generalized (analytic) continued fraction of the form \( f = a_0/(b_0 + a_1/(b_1 + a_2/(b_2 + \dots))) \) and lists its successive convergents \( f_0, f_1, f_2, \dots \) up to a chosen number of terms. The partial numerators \( a_n \) and partial denominators \( b_n \) are entered as algebraic expressions in the term index \( n \), so you can reproduce many classic expansions: pi, \( 1/(e-1) \), the natural log of root two, root two, and countless others. It is a pure-math tool with no units or country scope.

How to use it

Enter the initial numerator a0 and initial denominator b0 as numbers. Enter the n-th numerator \( a_n \) and n-th denominator \( b_n \) as expressions in the variable \( n \) - for example "n^2", "n+1", "-n^2", "3(2n+1)" or "2". Implicit multiplication next to \( n \) is supported, along with + - * / ^, parentheses, unary minus and functions like sqrt, exp, ln, sin and cos. Choose how many terms to evaluate (1 to 1000) and how many display digits to show. The big number is the last convergent; the table shows how the value settles.

The formula explained

To compute the n-th convergent \( f_n \) the calculator works from the deepest kept term outward. Set the tail \( t = 0 \), then for \( k = n, n-1, \dots, 1 \) update $$t = \frac{a_k}{b_k + t}.$$ Finally $$f_n = \frac{a_0}{b_0 + t}.$$ This bottom-up scheme is numerically clean, and a small epsilon is substituted whenever a denominator would be exactly zero (a modified Lentz safeguard).

Recurrence diagram showing numerator and denominator A_n and B_n built from previous terms
Convergents are computed by the recurrence \( A_n = b_n A_{n-1} + a_n A_{n-2} \) (and likewise for \( B_n \)).
Nested fraction structure of a generalized continued fraction with terms a0, b0, a1, b1, a2, b2
The nested structure of a generalized continued fraction: each level adds a new \( a_n \) over \( b_n \).

Worked example: the pi expansion

With \( a_0 = 4 \), \( b_0 = 1 \), \( a_n = n^2 \), \( b_n = 2n+1 \) and 6 terms you get the famous continued fraction for pi. Working bottom up at \( n = 6 \): \( t \) starts at 0; \( k=6 \) gives \( 36/13 = 2.769231 \); \( k=5 \) gives \( 25/13.769231 = 1.815651 \); \( k=4 \) gives \( 1.479323 \); \( k=3 \) gives \( 1.061407 \); \( k=2 \) gives \( 0.659912 \); \( k=1 \) gives \( 0.273156 \). Then $$f_6 = \frac{4}{1 + 0.273156} = 3.141962,$$ already close to \( \pi = 3.141593 \). Increase the term count to converge further.

Sequence of convergents approaching the value pi on a number line
Successive convergents \( f_n \) oscillate and close in on the true value (here pi).

FAQ

Why does the value not match the constant exactly? Each convergent is only a truncation. More terms means more accuracy, though double-precision limits useful digits to about 15.

What if my fraction diverges? Some expressions oscillate or diverge. The convergents table lets you watch the behaviour and decide whether a limit exists.

What other examples can I try? \( 1/(e-1) \): a0=1, b0=1, \( a_n=n+1 \), \( b_n=n+1 \). Root two: a0=2, b0=1, \( a_n=1 \), \( b_n=2 \). Natural log of root two: a0=1, b0=3, \( a_n=-n^2 \), \( b_n=3(2n+1) \).

Last updated: