Function Approximation by Continued Fraction Expansion
Approximate eˣ, log(1+x), arctan(x), and tan(x) with continued-fraction expansions, and watch convergence and the error against the true value in a chart and table as you add more terms.
Input
The closer x is to 0, the faster it converges with fewer terms. Increase the number of terms when |x| is large.
Result
Continued-fraction approximation of exp(x) = eˣ (x = 1, 10 terms)
2.71828183
True value (standard function)
2.71828183
Absolute error
2.77e-10
|approximation − true value|
Terms
10 terms
Error convergence (vertical axis: absolute error, log scale)
Convergence by number of terms
| Terms | Approximation | Absolute error |
|---|---|---|
| 1 | 2 | 7.18e-1 |
| 2 | 3 | 2.82e-1 |
| 3 | 2.75 | 3.17e-2 |
| 4 | 2.71428571 | 4.00e-3 |
| 5 | 2.71794872 | 3.33e-4 |
| 6 | 2.71830986 | 2.80e-5 |
| 7 | 2.71828358 | 1.75e-6 |
| 8 | 2.71828172 | 1.10e-7 |
| 9 | 2.71828182 | 5.52e-9 |
| 10 | 2.71828183 | 2.77e-10 |
How it works
- A continued fraction expansion approximates a function as a nested fraction of the form b0 + a1/(b1 + a2/(b2 + …)). It often converges faster than a Taylor series of the same order, so it is widely used for numerical evaluation of functions.
- Choose a function and enter the value of x you want to approximate along with the number of terms. The tool shows, in large type, the approximation obtained by truncating the continued fraction at the given number of terms, together with the true value from the standard function and the absolute error between them.
- Watch the approximation approach the true value as you add terms, compared side by side in a semi-log error chart (logarithmic vertical axis) and a table of the approximation and error for each number of terms. You can feel just how quickly the error shrinks.
- Convergence is faster with fewer terms the closer x is to 0. Note that it slows down near singularities or the edge of the domain, such as x near ±π/2 for tan(x) or x near -1 for log(1+x).
- This tool is intended for learning how convergence works and how approximation accuracy differs between functions. When high precision is required in practice, choose an appropriate number of terms for the value of x and check for overflow.
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 →