Calculus, Linear Algebra & Discrete Math Limits, Sequences & Series Taylor's theorem with the Lagrange form of the remainder

Taylor & Maclaurin Series Calculator

A Taylor polynomial matches a function's value and its first N derivatives at one chosen point, and then behaves like the function near it. This calculator differentiates your expression symbolically up to the degree you pick, builds every coefficient as a derivative divided by a factorial, evaluates the polynomial at your point, and compares the truncation error against the Lagrange remainder bound. Setting the centre to zero gives the Maclaurin series. The term table shows each derivative, coefficient and partial sum so you can see the approximation converge.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Function f(x)Use ^ for powers, * for multiplication (2*x, 2x and a plain space all work, so x sin(x) is read as a product), and the function names sin, cos, tan, sec, csc, cot, asin, acos, atan, sinh, cosh, tanh, exp, ln, log (base 10), sqrt, cbrt and abs. The constants pi and e are recognised.e^x
Centre aThe point where the polynomial matches f and its derivatives. Zero gives a Maclaurin series.0
Degree NHighest power kept. Higher degrees improve accuracy near the centre but cost more differentiation.4
Evaluate at xWhere to compare the polynomial against the true function.1

It returns

  • Taylor polynomial at your x — The sum of all terms up to degree N.
  • Exact value of f there
  • Truncation error
  • Lagrange remainder bound — Built from the largest absolute derivative of order N+1 between the centre and your point.
  • Taylor polynomial

The formula

f(x)n=0Nf(n)(a)(xa)nn!
RN(x)=f(N+1)(ξ)(xa)N+1(N+1)!

In plain text: f(x) ≈ Σ f⁽ⁿ⁾(a)·(x − a)ⁿ / n!, summed from n = 0 to N

  • aCentre of the expansion; a = 0 gives the Maclaurin series (units of x)
  • NHighest power retained (count)
  • f⁽ⁿ⁾(a)The nth derivative of f evaluated at the centre (units of f per unit of x to the n)
  • n!Factorial of n, which cancels the factor differentiation would produce (—)

The factorial divisor is exactly what makes the construction work: differentiating the nth term n times returns f⁽ⁿ⁾(a) and kills every other term, so the polynomial matches all N derivatives at the centre.

Updated Category Limits, Sequences & Series Verified against published test cases Reading time 9 min

Matching derivatives instead of matching points

Most approximation schemes force a polynomial through several points on a curve. Taylor's does something different: it forces the polynomial to agree with the function at one point, but to agree there in value, slope, curvature and every higher derivative up to order N. All the information is gathered at a single place, which is why the result is superb near that place and can be terrible far from it.

Degree 1 is a familiar object: f(a) + f′(a)(x − a) is exactly the tangent line. Degree 2 adds f″(a)(x − a)²/2 and bends the line into the parabola with the right curvature. Each further degree pins down one more derivative.

The factorials are not decoration. Differentiating (x − a)ⁿ exactly n times produces n!, so dividing by n! in the coefficient cancels it and leaves f⁽ⁿ⁾(a) standing alone. Every other term either vanishes or still carries a factor of (x − a) that dies at the centre. That is the whole design.

When the centre is zero the construction is called a Maclaurin series, which is not a different idea — just the common case, and the one that gives the tidy expansions of e^x, sin x and cos x that everyone memorises.

How big the error is, and what controls it

Taylor's theorem does not merely assert that the polynomial is close; it gives the error exactly. The remainder after degree N is f⁽ᴺ⁺¹⁾(ξ)(x − a)^(N+1)/(N+1)! for some unknown point ξ between the centre and your evaluation point. Bounding the unknown derivative by its maximum on that span turns the equality into the usable inequality this calculator reports.

Three things control the error. The distance from the centre, raised to the power N + 1, which is why accuracy collapses as you move away. The factorial in the denominator, which grows extremely fast and is why raising the degree helps so much near the centre. And the size of the next derivative, which is a property of the function you cannot change.

For e^x about zero evaluated at 1, the next derivative is e^ξ with ξ between 0 and 1, so the maximum is e = 2.71828. At degree 4 the bound is 2.71828 × 1⁵/120 = 0.0226524. The measured error is 0.0099485, comfortably below it. As always, the bound assumes the worst case at every point and the true error does better.

Convergence is not guaranteed everywhere. The Maclaurin series for 1/(1 − x) converges only for |x| < 1, and the radius of convergence is exactly the distance from the centre to the nearest singularity. Outside it, adding terms makes the approximation worse rather than better; the radius of convergence calculator finds that boundary.

Worked example: the Maclaurin polynomial of e^x to degree 4, evaluated at x = 1

This is the default setup.

  1. Derivatives. Every derivative of e^x is e^x, so f⁽ⁿ⁾(0) = 1 for every n.
  2. Coefficients. cₙ = 1/n!, giving 1, 1, 1/2, 1/6, 1/24.
  3. The polynomial. P₄(x) = 1 + x + x²/2 + x³/6 + x⁴/24.
  4. Evaluate at x = 1. 1 + 1 + 0.5 + 0.1666667 + 0.0416667 = 2.7083333.
  5. Compare. e = 2.7182818, so the error is 0.0099485 — about four parts in a thousand.
  6. Bound it. max|f⁽⁵⁾| = e = 2.7182818 on [0, 1], so R₄ ≤ 2.7182818 × 1/120 = 0.0226524. The measured error sits below the bound.

Now watch the degree work. Adding the degree-5 term contributes 1/120 = 0.0083333, taking the partial sum to 2.7166667 and the error to 0.0016152. Degree 6 adds 1/720 = 0.0013889, reaching 2.7180556 with an error of 0.0002263. Each extra term divides the error by roughly the next integer, which is the factorial at work.

And watch the distance work against you. The same degree-4 polynomial evaluated at x = 3 gives 1 + 3 + 4.5 + 4.5 + 3.375 = 16.375 against a true e³ = 20.0855369, an error of 3.7105369. The distance tripled and the error grew by a factor of about 373, because the error carries (x − a)⁵ and 3⁵ = 243, with the larger fifth derivative on [0, 3] supplying the rest.

How to read the term table

The derivative column is the raw material. These are f⁽ᵏ⁾(a), the numbers a hand calculation spends most of its time producing. For sin x about zero they cycle through 0, 1, 0, −1; for e^x they are all 1.

The coefficient column divides by k factorial. Notice how fast it shrinks even when the derivatives do not: by k = 8 the factorial is 40320, so a derivative of order one contributes only 0.0000248 per unit of (x − a)⁸.

The term column includes the distance factor. A term is small either because its coefficient is small or because (x − a) is small. Near the centre the second effect dominates; far from it, the first cannot rescue you.

The partial sum column is the answer at each degree. Reading down it shows the approximation converging, and the size of the last change is a practical error estimate — often a better one than the Lagrange bound, which is deliberately pessimistic. If the partial sums are not settling, your point is probably outside the radius of convergence.

Standard Maclaurin series

Expansions about a = 0, with the interval on which each converges. These are the series worth memorising.
FunctionMaclaurin seriesConverges for
e^x1 + x + x²/2! + x³/3! + x⁴/4! + …all x
sin xx − x³/3! + x⁵/5! − x⁷/7! + …all x
cos x1 − x²/2! + x⁴/4! − x⁶/6! + …all x
1/(1 − x)1 + x + x² + x³ + x⁴ + …|x| < 1
ln(1 + x)x − x²/2 + x³/3 − x⁴/4 + …−1 < x ≤ 1
arctan xx − x³/3 + x⁵/5 − x⁷/7 + …|x| ≤ 1
(1 + x)^k1 + kx + k(k−1)x²/2! + …|x| < 1 for non-integer k
sinh xx + x³/3! + x⁵/5! + …all x
cosh x1 + x²/2! + x⁴/4! + …all x

The sine and cosine series contain only odd and only even powers respectively, which is the algebraic statement that one function is odd and the other even. The hyperbolic pair are the same series with every sign made positive.

Where Taylor expansions go wrong

  • Forgetting the factorial. Writing f⁽ⁿ⁾(a)(x − a)ⁿ without dividing by n! destroys the whole construction; the polynomial then matches none of the derivatives beyond the first.
  • Using powers of x when the centre is not zero. The variable of a Taylor polynomial is (x − a), not x. Expanding about a = 4 and writing x⁴ instead of (x − 4)⁴ gives a completely different function.
  • Evaluating outside the radius of convergence. The series for 1/(1 − x) diverges at x = 2 no matter how many terms you take. More terms make it worse, not better.
  • Assuming higher degree always helps. It helps near the centre. Far from it, the distance factor (x − a)^(N+1) can grow faster than the factorial shrinks, at least until N becomes large.
  • Treating the Lagrange bound as the error. It is an upper bound built from the worst case of the next derivative, and the true error is usually well below it.
  • Expanding about a point where a derivative fails to exist. ln x has no Maclaurin series because it is undefined at zero; the natural centre is a = 1, which is why the standard series is written for ln(1 + x).

What Taylor polynomials are actually used for

Evaluating functions. Underneath every library implementation of a transcendental function is a polynomial or rational approximation, usually a refined descendant of a Taylor expansion, chosen because a processor multiplies and adds and does nothing else.

Resolving indeterminate limits. Substituting series is often faster and clearer than repeated differentiation. (1 − cos x)/x² becomes (x²/2 − x⁴/24 + …)/x², which visibly tends to 1/2. Compare that with L'Hôpital's rule, which needs two rounds of differentiation to reach the same answer.

Linearising models. Physics and engineering are full of small-angle and small-signal approximations, and every one of them is a truncated Taylor series: sin θ ≈ θ for the pendulum, (1 + x)^k ≈ 1 + kx for relativistic and thermodynamic corrections.

Deriving numerical methods. Finite-difference formulas, Euler's method, Runge-Kutta and Newton's method are all constructed by truncating Taylor expansions, and their orders of accuracy are the orders of the terms discarded.

Integrating the unintegrable. e^(−x²) has no elementary antiderivative, but its series does: integrate term by term and you get a series for the error function that converges rapidly near zero.

Frequently asked questions

What is the difference between a Taylor series and a Maclaurin series?

None, except the centre. A Maclaurin series is a Taylor series with a = 0. Set the centre to zero in this calculator and you get the Maclaurin expansion; set it anywhere else and you get the general Taylor expansion about that point, written in powers of (x − a).

Why do the coefficients have factorials in them?

Because differentiating (x − a)ⁿ exactly n times produces n!, and the coefficient must cancel it so that the nth derivative of the polynomial at the centre equals f⁽ⁿ⁾(a). Without the division the polynomial would match only the value and the first derivative, and every higher match would be off by a factorial.

How many terms do I need?

Read the partial sum column and stop when the change between successive rows is smaller than your tolerance. That is usually a sharper guide than the Lagrange bound, which assumes the worst case. Near the centre a handful of terms is plenty; far from it no reasonable degree may suffice.

Why does my approximation get worse as I add terms?

Because your evaluation point lies outside the radius of convergence. For 1/(1 − x) centred at zero the radius is 1, so at x = 2 the terms are 1, 2, 4, 8, … and the partial sums run away. The radius is the distance from the centre to the nearest point where the function misbehaves.

Can I expand around a point where the function is undefined?

No. Every coefficient requires a derivative evaluated at the centre, so the function and all its derivatives up to order N must exist there. ln x has no expansion about zero, which is why textbooks state the series for ln(1 + x) — that is the same function centred at 1.

Why is the degree limited to eight?

Because symbolic derivatives of composite functions grow very quickly. The eighth derivative of something like e^(x²) already has hundreds of nodes, and beyond that the expressions cost far more to build than the extra accuracy is worth in a browser. The calculator also stops early and says so if an expression outgrows its size limit before reaching your chosen degree.

What does the Lagrange bound actually guarantee?

That the true error is no larger than the bound, provided the derivative of order N+1 is continuous between the centre and your point. It is built by replacing the unknown intermediate point in the exact remainder with whichever value maximises the derivative, so it is a worst case rather than a prediction. Measured errors typically land a factor of two or more below it.

Is the degree-1 Taylor polynomial the same as the tangent line?

Yes, exactly. P₁(x) = f(a) + f′(a)(x − a) is the tangent line equation, and its error term carries (x − a)², which is the squared-distance rule quoted for linear approximation. Every statement about linearisation is the N = 1 case of Taylor's theorem.

References

  • Calculus, 8th edition (Taylor and Maclaurin series, sections 11.10-11.11) — James Stewart, Cengage Learning
  • Principles of Mathematical Analysis, 3rd edition (Taylor's theorem, chapter 5) — Walter Rudin, McGraw-Hill
  • Handbook of Mathematical Functions, Chapter 4: Elementary Transcendental Functions — Abramowitz & Stegun, National Bureau of Standards