Don Stephenson Don Stephenson

Taylor Series Expansion

A polynomial that agrees with f and all its derivatives at one point

This instrument shows how Pₙ(x) = Σ f⁽ᵏ⁾(a)/k! · (x−a)ᵏ builds a local polynomial approximation of f(x) around an expansion point a. Pick a function, drag the center a or the order n, and watch the copper curve fold itself onto the teal one — and watch it fall apart again outside the radius of convergence.

Taylor Series

Pₙ(x) = Σ f⁽ᵏ⁾(a)/k!·(x−a)ᵏ  ·  each term matches one more derivative of f at x = a
f(x) vs the degree-n Taylor polynomial about x = a f(x) Pₙ(x) center a
Expansion
f(a)0
Pₙ(a)0
Max |error| on view0
Function
DRAG THE ORDER OR CENTER SLIDER · PICK A FUNCTION TO RESET

This tool builds a polynomial approximation of a function around a chosen point and draws it against the real thing — a hand-rolled canvas renderer, no plotting library. The sections below explain what each term in the polynomial is actually doing, and why the approximation eventually falls apart outside a fixed radius no matter how many terms you add.

1. Match the value, then the slope, then the curvature…

A Taylor polynomial of degree $n$ centered at $x=a$ is built term by term so that it agrees with $f$ and its first $n$ derivatives, all evaluated at that single point $a$: $$P_n(x) = \sum_{k=0}^{n} \frac{f^{(k)}(a)}{k!}(x-a)^k$$ The $k{=}0$ term just copies the value $f(a)$. Adding the $k{=}1$ term makes the polynomial match $f$'s slope at $a$ too. Adding $k{=}2$ matches curvature as well, and so on — every extra term is one more matched derivative, which is exactly why the copper curve in this tool hugs the teal one more tightly near $x=a$ as you drag the order slider up.

2. Why the $k!$ in the denominator

Differentiate $P_n(x)$ $k$ times and evaluate at $x=a$: every term except the $k$-th vanishes (its derivative is either zero or still has a factor of $(x-a)$ that zeroes out at $x=a$), and the $k$-th term's own repeated differentiation of $(x-a)^k$ brings down a factor of $k(k-1)(k-2)\cdots 1 = k!$. Dividing by $k!$ up front is what cancels that factor back out, so the coefficient really does equal the $k$-th derivative at $a$ — not $k!$ times too large.

3. Centering at $a\neq 0$ just shifts where the matching happens

When $a=0$ this is often called a Maclaurin series; dragging the center slider away from 0 doesn't change the idea at all, only where the derivatives are measured from. The polynomial always hugs $f(x)$ tightest right at $x=a$ and drifts away as $x$ moves further from it — which is exactly what "local approximation" means, and exactly why re-centering can rescue a bad approximation far from the origin.

4. Outside the radius of convergence, more terms make it worse

For some functions the series only matches $f(x)$ within a finite distance of $a$, called the radius of convergence; past it, adding more terms doesn't slowly improve the fit, it makes the polynomial diverge faster. $\ln(1+x)$ and $1/(1-x)$ in this tool's function list both have a radius of exactly 1 when centered at $a=0$, because both blow up at $x=-1$ or $x=1$ respectively — the series can't "see" past a function's own singularity. $\sin x$, $\cos x$, and $e^x$ have no such wall: their series converge for every real $x$, which is why those three curves never fall apart no matter how far you drag the view.

5. Five series worth recognizing on sight

The function picker's five choices are the classic Maclaurin expansions ($a=0$) most other series in calculus and engineering reduce to:

  • $\sin x = x - \dfrac{x^3}{3!} + \dfrac{x^5}{5!} - \cdots$ — odd powers only, converges everywhere.
  • $\cos x = 1 - \dfrac{x^2}{2!} + \dfrac{x^4}{4!} - \cdots$ — even powers only, converges everywhere.
  • $e^x = 1 + x + \dfrac{x^2}{2!} + \dfrac{x^3}{3!} + \cdots$ — every derivative of $e^x$ is $e^x$, so every coefficient is $1/k!$.
  • $\ln(1+x) = x - \dfrac{x^2}{2} + \dfrac{x^3}{3} - \cdots$ — radius of convergence 1.
  • $\dfrac{1}{1-x} = 1 + x + x^2 + x^3 + \cdots$ — the geometric series; radius of convergence 1.

6. Pedagogical flow

  1. Pick sin(x), center a = 0, and step the order up from 0: watch the flat line become a tilted line, then a parabola-like curve, then fold onto the sine wave.
  2. Switch to 1/(1−x) at the same order and notice the fit is already visibly worse past x≈1, even at high order.
  3. Drag the center a for ln(1+x) toward 1 and watch the usable range of good approximation shift with it.
  4. Use the Animate button on $e^x$ and watch the max-error stat shrink toward zero as the order climbs — there's no radius wall to hit.