The Lagrange Error Bound

How far a Taylor polynomial can be off.

What is left over

A Taylor polynomial stops after a few terms, and the terms it leaves out add up to something. Write Pₙ(x) for the polynomial of degree n and Rₙ(x) for the remainder, so that f(x) = Pₙ(x) + Rₙ(x). The remainder is the error made by using the polynomial instead of the function.

For sin x, the polynomial of degree 3 is P₃(x) = x − x³/6. At x = 1 it gives 5/6 = 0.833333, and sin 1 = 0.841471, so the remainder there is R₃(1) = 0.008138. Without knowing sin 1 in advance, how large could that error be?

The bound

The Lagrange error bound says that |Rₙ(x)| ≤ M|x − a|ⁿ⁺¹ / (n + 1)!, where a is the center of the series and M is any number at least as large as the size of the (n + 1)th derivative, |f⁽ⁿ⁺¹⁾(t)|, for every t between a and x.

It is an upper bound, not the error itself. The true error can be anything from 0 up to the bound, and it is usually smaller.

Where it comes from

There is an exact formula for the remainder: Rₙ(x) = f⁽ⁿ⁺¹⁾(c)(x − a)ⁿ⁺¹/(n + 1)! for some number c between a and x. It has the shape of the next term of the series, except that the derivative is taken at c instead of at a.

When n = 0 this is the mean value theorem: f(x) − f(a) = f'(c)(x − a), the change in f equals the gradient at some point c times the step.

The formula says that such a c exists, but not where it is. So the derivative at c is replaced by M, the largest size it could have anywhere between a and x. That is the bound: the next term, with its unknown derivative replaced by its largest size.

sin x to degree 3

Take P₃(x) = x − x³/6, centered at 0, on −1 ≤ x ≤ 1. The bound needs the fourth derivative. The derivatives of sin x are cos x, −sin x, −cos x and then sin x again, so f⁽⁴⁾(t) = sin t, and its size is never more than 1. So M = 1.

With n = 3, |R₃(x)| ≤ 1 × |x|⁴/4! = |x|⁴/24. The largest value on −1 ≤ x ≤ 1 is at x = ±1: 1/24 = 0.041667. The error is at most 0.041667 anywhere on the interval.

The true error at x = 1 is 0.008138, about a fifth of the bound, and at x = 0.5 it is 0.000259 against a bound of 0.5⁴/24 = 0.002604. The bound holds at every x, and it is never smaller than the error.

A sharper bound is free here. sin x has no x⁴ term, so P₃ is also P₄, the polynomial of degree 4, and the bound with n = 4 uses the fifth derivative, cos t, again of size at most 1: |R₄(x)| ≤ |x|⁵/5!. At x = 1 that is 1/120 = 0.008333, just above the true error 0.008138.

x

The gold curve is the true error |sin x − P₃(x)|, and the plain one is the bound |x|⁴/24, for x from −1 to 1. The bound lies above the error everywhere. At x = 1 the bound is 0.041667 and the error is 0.008138.

Choosing M

For sine every derivative is at most 1 in size, so M is easy. For other functions, M has to be found on the interval between a and x, and it depends on which side of a the point x lies.

Take eˣ with P₂(x) = 1 + x + x²/2. The third derivative is eᵗ, which is largest at the right-hand end of any interval. At x = 0.5 the interval is 0 ≤ t ≤ 0.5, and e^0.5 is less than 2, because e < 3 and so e^0.5 < √3 < 2. So M = 2 will do. The bound is 2 × 0.5³/3! = 0.041667. The polynomial gives 1.625 and e^0.5 = 1.648721, so the true error is 0.023721, inside the bound.

At x = −0.5 the interval is −0.5 ≤ t ≤ 0, where eᵗ is at most e⁰ = 1, so M = 1 and the bound is 0.5³/3! = 0.020833. The polynomial gives 0.625 and e^(−0.5) = 0.606531, an error of 0.018469, again inside the bound.

How many terms are enough

The bound can be used before any calculating is done, to decide how many terms a given accuracy needs. Suppose e must be found from 1 + 1 + 1/2! + 1/3! + … with an error of at most 0.001. Here x = 1 and a = 0, and every derivative of eˣ is eᵗ ≤ e¹ < 3 on 0 ≤ t ≤ 1, so M = 3 and the bound for degree n is 3/(n + 1)!.

For n = 5 that is 3/720 = 0.004167, too large. For n = 6 it is 3/5040 = 0.000595, which is below 0.001, so the terms up to 1/6! are enough. They add up to 2.718056, and e = 2.718282, so the true error is 0.000226.

-2π−ππ2πP3(x) = x − x³/3!within 0.01 for |x| ≤ 1.04N = 3

P3 stays within 0.01 of sin x for |x| ≤ 1.04: each extra degree matches one more derivative at 0, so the polynomial hugs the curve further before it flies away

Step the degree until the polynomial stays within 0.01 of sin x out to π

The plain curve is y = sin x and the gold one is x − x³/3!. The shaded band is where the two differ by at most 0.01, out to |x| = 1.04. The Lagrange bound |x|⁵/5! is at most 0.01 for |x| up to 1.037, so it guarantees nearly all of that band before any error is measured. Drag N to 5 and the band reaches 1.76, with the bound guaranteeing 1.751; at N = 7 it reaches 2.5, with the bound guaranteeing 2.486.

The usual mistakes

Using the wrong derivative. The bound for degree n uses the (n + 1)th derivative and divides by (n + 1)!. For sin x to degree 3 that is 4! = 24, not 3! = 6.

Taking M at the center only. M must bound the derivative at every point between a and x. For eˣ at x = 0.5, e⁰ = 1 is too small; the derivative reaches e^0.5 at the far end.

Counting terms as the degree. Three terms of the sine series, x − x³/3! + x⁵/5!, reach degree 5, so their bound uses x⁷/7!, not x⁴/4!.

Reading the bound as the error. 1/24 is the most the error of P₃ can be on −1 ≤ x ≤ 1; the actual error at x = 1 is 0.008138.

A calculator’s sine key

In the application below, a calculator works out sin 0.5 from the sine series and has to be right to six decimal places. The Lagrange bound, with M = 1, shows that three terms are not enough and four are.

Worked example: A Calculator's Sine Key: How Many Terms Six Decimal Places Need

Question A calculator works out sin 0.5, the angle being in radians, from the Maclaurin series sin x = x − x33! + x55! − …, and it must be right to 6 decimal places. (a) Work out the estimate from the first three terms, and use the Lagrange error bound to show that three terms are not enough. (b) How many terms are enough, and what is sin 0.5 to 6 decimal places?

  1. 1.Take the first three terms at x = 0.5: 0.5 − 0.536 + 0.55120 = 0.5 − 0.0208333 + 0.0002604 = 0.4794271.

    termsdegreeerror bound230.0026350.0000217470.00000010.5 − 0.0208333 + 0.0002604 = 0.4794271
    termsdegreeerror bound230.0026350.0000217470.00000010.5 − 0.0208333 + 0.0002604 = 0.4794271
    Three terms at x = 0.5: 0.5 − 0.536 + 0.55120 = 0.4794271.
  2. 2.Bound the error. For a Taylor polynomial of degree n the Lagrange bound is M|x|n+1(n+1)!, where M bounds the (n+1)th derivative. Every derivative of the sine is ±sin or ±cos, so M = 1 serves for all of them. Three terms reach degree 5, so the error is at most 0.566! = 0.015625720 ≈ 0.0000217.

    termsdegreeerror bound230.0026350.0000217470.00000010.5 − 0.0208333 + 0.0002604 = 0.47942710.56divided by 720 = 0.0000217
    termsdegreeerror bound230.0026350.0000217470.00000010.5 − 0.0208333 + 0.0002604 = 0.47942710.56divided by 720 = 0.0000217
    Three terms reach degree 5, so the bound is 0.566! ≈ 0.0000217.
  3. 3.(a) Six decimal places need the error below half a unit in the sixth place, which is 0.0000005. The bound 0.0000217 is far above that, so three terms cannot be trusted to 6 places, and in fact they are wrong there: the true value is 0.4794255, so the three-term estimate is out by about 0.0000015.

    termsdegreeerror bound230.0026350.0000217470.00000010.5 − 0.0208333 + 0.0002604 = 0.47942710.56divided by 720 = 0.0000217six places need under 0.0000005
    termsdegreeerror bound230.0026350.0000217470.00000010.5 − 0.0208333 + 0.0002604 = 0.47942710.56divided by 720 = 0.0000217six places need under 0.0000005
    (a) Six places need an error under 0.0000005, so three terms are not enough.
  4. 4.Try four terms, a polynomial of degree 7. The bound becomes 0.588! = 0.0039062540320 ≈ 0.000000097, which is below 0.0000005, so four terms are enough.

    termsdegreeerror bound230.0026350.0000217470.00000010.5 − 0.0208333 + 0.0002604 = 0.47942710.56divided by 720 = 0.0000217six places need under 0.00000050.58divided by 40320 = 0.0000001
    termsdegreeerror bound230.0026350.0000217470.00000010.5 − 0.0208333 + 0.0002604 = 0.47942710.56divided by 720 = 0.0000217six places need under 0.00000050.58divided by 40320 = 0.0000001
    Four terms reach degree 7, and 0.588! ≈ 0.000000097 is small enough.
  5. 5.(b) Four terms give 0.5 − 0.536 + 0.55120 − 0.575040 = 0.4794255, and sin 0.5 = 0.479426 to 6 decimal places.

    termsdegreeerror bound230.0026350.0000217470.00000010.5 − 0.0208333 + 0.0002604 = 0.47942710.56divided by 720 = 0.0000217six places need under 0.00000050.58divided by 40320 = 0.0000001sin 0.5 = 0.479426
    termsdegreeerror bound230.0026350.0000217470.00000010.5 − 0.0208333 + 0.0002604 = 0.47942710.56divided by 720 = 0.0000217six places need under 0.00000050.58divided by 40320 = 0.0000001sin 0.5 = 0.479426
    (b) Four terms, and sin 0.5 = 0.479426 to six decimal places.

Answer: (a) 0.4794271, with an error bound of 0.0000217, which is too large for 6 decimal places; (b) four terms, and sin 0.5 = 0.479426

Common mistakes

  • Reading "6 decimal places" as "an error below 0.000001". The sixth place is settled only when the error is below half a unit in it, which is 0.0000005; a bound of 0.0000009 would leave the sixth digit in doubt.
  • Counting terms and degrees as the same number. Three terms of the sine series reach degree 5, not degree 3, because the even powers are missing. Putting n = 3 into the bound gives 0.544! ≈ 0.0026 and overstates the error by a factor of more than a hundred.

More series and convergence problems, worked step by step →

Practice The Lagrange Error Bound in the app