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).
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.
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) \).