Compute the Taylor polynomial expansion of any function f(x) around a center a, up to degree n. Visualize the approximation, view each derivative term, and estimate the error at any evaluation point x.
In calculus, a Taylor polynomial is a polynomial approximation of a function f(x) near a specific point a (the center). For a function that is sufficiently smooth (differentiable) at a, the Taylor polynomial of degree n is given by:
where f(k)(a) denotes the k‑th derivative of f evaluated at a, and k! is the factorial of k.
The Taylor polynomial is the best polynomial approximation of degree n near a, in the sense that its derivatives up to order n match those of f at a. As n increases, the polynomial typically converges to f over an interval known as the radius of convergence. When a = 0, the expansion is also called a Maclaurin series.
The difference between f(x) and its Taylor polynomial is called the remainder or truncation error:
Lagrange form of the remainder: If f is (n+1)‑times differentiable, then for some ξ between a and x, Rn(x) = f(n+1)(ξ) / (n+1)! · (x − a)n+1
This remainder formula provides a way to bound the error of the Taylor approximation. For example, if |f(n+1)(t)| ≤ M for all t between a and x, then |Rn(x)| ≤ M · |x − a|n+1 / (n+1)!. This is the foundation of many numerical methods in scientific computing, physics, and engineering.
The calculator uses symbolic differentiation via the math.js library to compute the exact derivatives of f(x) at the center a. For each degree k from 0 to n, it:
For functions where symbolic differentiation fails (e.g., piecewise or highly nested functions), the tool falls back to numerical differentiation using a high‑precision central difference scheme with adaptive step size. This ensures robust operation for a wide variety of inputs.
The graph displays the original function f(x) (blue) and the Taylor polynomial Pn(x) (red) over a user‑adjustable interval around the center a. The center point is marked in green, and the evaluation point x is shown in gray. The error at x is computed as the absolute difference between f(x) and Pn(x), and also displayed as a percentage.
| Function | Taylor expansion at a = 0 | Radius of convergence |
|---|---|---|
| sin(x) | x − x³/3! + x⁵/5! − x⁷/7! + … | ∞ |
| cos(x) | 1 − x²/2! + x⁴/4! − x⁶/6! + … | ∞ |
| ex | 1 + x + x²/2! + x³/3! + x⁴/4! + … | ∞ |
| ln(1+x) | x − x²/2 + x³/3 − x⁴/4 + … | 1 |
| 1/(1−x) | 1 + x + x² + x³ + x⁴ + … | 1 |
| √(1+x) | 1 + x/2 − x²/8 + x³/16 − 5x⁴/128 + … | 1 |
| tan(x) | x + x³/3 + 2x⁵/15 + 17x⁷/315 + … | π/2 |
In classical mechanics, the small‑angle approximation for a pendulum replaces sin(θ) with θ (the first‑degree Taylor polynomial). For small angles (θ ≪ 1), this simplification yields the linear differential equation for harmonic motion. Using our calculator, set f(x) = sin(x), a = 0, n = 1, and evaluate at θ = 0.1 rad: the error is negligible (~0.0167%). At θ = 0.5 rad, the error grows to about 4.2%, showing the limits of the approximation. Increase n to 3 or 5 to see improved accuracy — a perfect demonstration of Taylor's theorem in action.
sin(x), exp(x), log(1+x), x^2 + 2*x + 1).
sin(x), cos(x), tan(x), exp(x), log(x) (natural log), sqrt(x), x^2, x^3, and combinations like sin(x^2), exp(-x^2), log(1+x), etc. The calculator uses math.js to parse and differentiate the expression symbolically.