Taylor Series

Approximate any smooth curve by a polynomial that agrees with it at one point. Add terms and watch the agreement spread.

Overview

The construction

Pick a point. Build a polynomial that agrees with the function there, then also agrees with its slope, then its curvature, then the next deriv, and so on.

f(x)  ~  f(a) + f'(a)(x-a) + f''(a)(x-a)^2/2! + f'''(a)(x-a)^3/3! + ...

Each term pins down one more deriv at a. The factorials are there because differentiating (x-a)^k again and again makes k!, and cutting by it cancels just.

Set the terms control to 0 and step it upward. At 0 you've a flat line at the right height. At 1, the tangent. At 2, a parabola that also has the right bend. Each step hugs the curve a little further out.

Taylor Series

This module needs JavaScript: the numbers are computed in the page rather than recorded.

Worth knowing

The series matches the function's value, then its slope, then its curvature, then the rate of change of curvature, and so on.
Each term buys accuracy near the expansion point. None of them buys accuracy far from it.
One term is a constant. Two is the tangent line. Three is the quadratic every optimiser secretly uses.
Move the expansion point and the region of agreement moves with it. It is a local statement, always.

Taylor Series

Replacing a hard function with a polynomial. Being precise about where that is allowed.

Local, and only local

The readout gives how far the guess stays within 0.1 of the truth, and this is the number worth watching.

More terms extend the range. They don't make it infinite, and the extension gets slower. The polynomial agrees just right at the expansion point and gets worse with distance, always — the whole build is built from info at a single point. So It can't know any of it about elsewhere.

Move the expansion point and the region of match moves with it. That is the right mental model: a Taylor series is a statement about a zone.

Where it earns its keep

Second-order optimisation. Newton's method is just the two-term expansion of the loss: rough it as a quadratic near the current point, jump to that quadratic's min, repeat. All in the Hessian module is this idea.

Small-angle guesses. sin(x) ~ x for small x is the one-term expansion, and it's why pendulum equations are solvable at all.

Backpropagation's justification. The chain rule is exact, but the arg that a small weight change makes a proportional loss change is a first-order expansion.

numeric methods. Finite differences, Runge-Kutta integrators and most error bounds are derived by expanding and discarding.

exp, log, sin in a standard library. Not looked up in a table. Tested from a truncated series with a range reduction in front of it.

Where it fails

Switch the function control to 1 / (1 + x squared).

This function is smooth all over on the real line — no kinks, no asymptotes, differentiable as many times as you like. Yet expand it about 0 and add terms, and beyond about x = 1 the guess doesn't merely fail to improve. It gets worse with each term added.

The reason is invisible from the real line. Viewed over the complex numbers the function has poles at *i* and *−i*, distance 1 from the origin, and the radius of settling is the distance to the nearest singularity wherever it sits. That radius is 1, and no number of real terms escapes it.

This is the Runge effect, and its lesson is hands-on: smooth on the reals doesn't mean a Taylor series settles all over. Adding terms isn't always progress.

Where it goes wrong with Taylor Series

Extrapolating far from the expansion point. The error grows with distance, and past the radius of settling it grows without bound.

given more terms is always better. Not past the radius, and not by number — high-order terms involve large factorials and cancelling quantities, which loses precision in floating point.

Expanding about the wrong point. Expand about where you'll test. A series about 0 is the wrong tool for guessing at x = 5.

Losing smoothness is needed. The function needs derivs of each order at the expansion point. |x| has none at 0. There's no series there.

e to the x, worked by hand

Expand e^x about a = 0. each deriv of e^x is e^x, and e^0 = 1, so each coeff is 1/k! and the series is as clean as they come:

e^x  ~  1 + x + x^2/2 + x^3/6 + x^4/24 + ...

Test it at x = 1. Here The true value is 2.718282, adding one term at a time:

termsvalueerror
11.00001.7183
22.00000.7183
32.50000.2183
42.66670.0516
52.70830.0099
62.71670.0016

Six terms and the error is under a tenth of a percent. Now the *same six terms* at x = 3, where the truth is 20.0855:

termsvalueerror
11.00019.09
24.00016.09
38.50011.59
413.0007.09
516.3753.71
618.4001.69

Still 8% out. The reason is visible in the term itself: the k-th term is x^k / k!, so the numerator grows like 3^k while the factorial doesn't overtake it until k passes 3. Near the expansion point the terms shrink from the start. Far from it they grow first and shrink later, and you've to push through that bulge before the series is any use. Matching at x = 3 the fit six terms gave at x = 1 takes eleven.

That is the whole "local, and only local" claim, in numbers: the same polynomial, unchanged, is great at one distance and unusable at three times it. It's also why real setups do range reduction first — e^3 is found as e^0.25 raised to a power, not by expanding at 3.

Questions people ask about Taylor Series

Taylor or Maclaurin? A Maclaurin series is a Taylor series with the expansion point at zero. That is the entire difference, and it's why the two words are used almost alike.

How many terms do I need? What makes the first term you dropped small enough. For a well-behaved alternating series the remainder is bounded by the size of that next term. This Makes it a truly hands-on stopping rule. Or else use the Lagrange remainder. This Bounds the error by the largest (n+1)-th deriv anywhere between the expansion point and where you're testing — and that bound is why the error grows with distance.

Why does 1/(1 + x²) break at x = 1 when it's smooth all over? Because the real line is the wrong place to look. Allow complex numbers and the function blows up at x = i and x = -i, both at distance 1 from the origin. A power series settles inside a *disc* reaching the nearest singularity in the complex plane, so the radius here is 1 even so of how well behaved the function looks on the reals. The failure is real. The cause is elsewhere.

Is the Taylor polynomial the best polynomial guess? No, and this surprises people. It's the best one *at the expansion point*, where it matches as many derivs as it has terms. Across an interval it's often beaten comfortably by a minimax or Chebyshev fit. This Spreads the error evenly instead of concentrating fit at one spot. numeric libraries use those, not Taylor, for just this reason.

Does a Taylor series always settle to the function? Not always. The standard counterexample is e^(-1/x^2) extended by zero at the origin: each deriv there's 0, so its series is the same way 0. This Agrees with the function at just one point. Smooth isn't enough. The property that makes the series work is called being *analytic*.

Rebuild a function from its derivatives

Terms added one at a time, with the error after each. The guess is great near the expansion point and hopeless far from it.

example_01.pyNumPy
Output

Check yourself

0 of 3

Answer without scrolling back up.

  1. What does the second term of a Taylor series give you?

  2. Why does the series for 1/(1+x^2) stop improving beyond x = 1?

  3. A Taylor series is a statement about:

Cheat sheet

Taylor Series

Expand a function into a polynomial term by term. Watch the approximation improve near the centre and fail past the radius of convergence.

MATHS · vizlearn.in/maths/taylor_series.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.