What this calculator does
This tool evaluates a continued fraction with constant terms: a continued fraction of the form \(f = b_0 + a/(b + a/(b + a/(b + \cdots)))\) where every partial numerator equals the same value \(a\) (your \(a_n\)) and every partial denominator equals the same value \(b\) (your \(b_n\)). The leading term \(b_0\) sits outside the fraction. It is a pure-mathematics tool and works the same everywhere.
How to use it
Enter the initial term b0, the constant numerator a_n, the constant denominator b_n, and the number of nested levels n (up to 1000). The calculator returns the truncated value \(f_n\) and a table of the early convergents \(f_1, f_2, f_3 \ldots\) so you can watch them settle on the limit.
The formula explained
The value is computed with a numerically stable backward (bottom-up) recurrence. Start at the innermost level with \(t = b\). Then for \(k\) from \(n\) down to 2, set \(t = b + a/t\). Finally \(f_n = b_0 + a/t\). The convergents table instead uses the classic Wallis recurrence \(h_m = b \cdot h_{m-1} + a \cdot h_{m-2}\) and \(k_m = b \cdot k_{m-1} + a \cdot k_{m-2}\), giving \(f_m = h_m/k_m\). When the fraction converges, the limit equals $$f = b_0 + \cfrac{-b + \sqrt{b^2 + 4a}}{2}$$
Worked example
Take \(b_0 = 1\), \(a_n = 1\), \(b_n = 2\), \(n = 10\). The backward recurrence runs $$t = 2 \to 2.5 \to 2.4 \to 2.41667 \to \cdots \to 2.41421,$$ and \(f_{10} = 1 + 1/t \approx 1.41421356\), which is the square root of 2. Indeed $$1 + \cfrac{1}{2 + \cfrac{1}{2 + \cdots}} = \sqrt{2}.$$
FAQ
What if it does not converge? If an intermediate denominator becomes exactly 0, or \(b^2 + 4a < 0\), the value may be undefined or oscillate; the calculator reports "undefined" in that case.
Why a constant a_n and b_n? Many famous constants arise this way: \(a=1\), \(b=1\) gives the golden ratio \(1.6180339887\); \(a=1\), \(b=2\) gives \(\sqrt{2}\). A constant tail has a simple quadratic limit.
How accurate is f_n? For constant terms convergence is geometric, so a few dozen terms usually reach full double precision.