AP Calculus BC

Lagrange Error Bound: Bounding Taylor Polynomial Error

If P_n is the degree n Taylor polynomial for f centered at a, then |f(x) - P_n(x)| <= M |x - a|^(n+1) / (n+1)!, where M is at least as large as the absolute value of the (n+1)st derivative of f everywhere between a and x. The bound is a ceiling on the error and is usually larger than the actual error.

The bound

A Taylor polynomial Pn(x)P_n(x) centered at x=ax = a approximates f(x)f(x) near aa (CED Topic 10.11, Finding Taylor Polynomial Approximations of Functions). The Lagrange error bound, CED Topic 10.12, limits how far off that approximation can be.

∣f(x)−Pn(x)∣≤M(n+1)! ∣x−a∣n+1\left| f(x) - P_n(x) \right| \le \frac{M}{(n+1)!}\,\left| x - a \right|^{n+1}

Here MM is a number satisfying ∣f(n+1)(z)∣≤M\left| f^{(n+1)}(z) \right| \le M for every zz between aa and xx. The right side has the same shape as the next term of the Taylor polynomial, with the derivative value replaced by its largest possible size on the interval.

Three inputs go into it: the degree nn of the polynomial, the distance ∣x−a∣|x - a| from the center, and the bound MM. Everything in the formula uses n+1n + 1: the derivative order, the factorial and the power.

Choosing M

Finding MM is the only step that takes judgment. MM does not have to be the exact maximum of ∣f(n+1)∣\left| f^{(n+1)} \right|. Any number that is at least as large works, and a simple overestimate is often the best choice.

SituationHow to get M
f(n+1)f^{(n+1)} is ±sin⁡\pm\sin or ±cos⁡\pm\cosUse M=1M = 1, since sine and cosine never exceed 11 in absolute value
∣f(n+1)∣\left| f^{(n+1)} \right| is increasing on the intervalUse its value at the endpoint farthest to the right
∣f(n+1)∣\left| f^{(n+1)} \right| is decreasing on the intervalUse its value at the left endpoint
The problem states a bound on f(n+1)f^{(n+1)}Use the stated bound
The maximum is an awkward number such as e0.5e^{0.5}Round up to a convenient value, such as 22

The interval that matters runs from the center aa to the point xx being approximated. MM must cover the whole interval. Evaluating the derivative only at the center is a common error and can give a value that is too small.

Three ways the bound is used

  • Bound the error of a given approximation. Compute M(n+1)!∣x−a∣n+1\frac{M}{(n+1)!}|x - a|^{n+1} and report it as the largest possible error.
  • Trap the true value. If the error is at most EE, then Pn(x)−E≤f(x)≤Pn(x)+EP_n(x) - E \le f(x) \le P_n(x) + E.
  • Find a degree that guarantees a required accuracy. Write the bound in terms of nn and increase nn until it falls below the tolerance.

For the third use, take sin⁡x\sin x approximated at x=1x = 1 by a Maclaurin polynomial. Every derivative of sine is bounded by 11, so the error is at most 1(n+1)!\frac{1}{(n+1)!}. To get this under 0.0010.001, compare factorials: 6!=7206! = 720 gives 1720≈0.00139\frac{1}{720} \approx 0.00139, which is too large, and 7!=50407! = 5040 gives 15040≈0.000198\frac{1}{5040} \approx 0.000198, which is small enough. So n+1=7n + 1 = 7, and the bound first guarantees the accuracy at degree n=6n = 6.

Lagrange bound or alternating series bound

Two error bounds appear in this unit, and they apply in different situations. The Lagrange bound works for any Taylor polynomial as long as you can bound the next derivative. The alternating series error bound (CED Topic 10.10) applies only when the Taylor series, evaluated at the given xx, is an alternating series whose terms decrease in size to 00. In that case the error is at most the size of the first omitted term, with no derivative needed.

When both apply, either one is valid, and the alternating bound is usually less work. When the series does not alternate at the given xx, such as the series for exe^x at a positive xx, the Lagrange bound is the one to use.

Common mistakes

  • Using the nnth derivative. The bound uses derivative number n+1n + 1.
  • Writing n!n! in the denominator or ∣x−a∣n|x - a|^n in the numerator. Both use n+1n + 1.
  • Evaluating f(n+1)f^{(n+1)} only at the center. MM must hold on the whole interval between aa and xx.
  • Using xx where x−ax - a belongs when the center is not 00.
  • Stating that the error equals the bound. Write that the error is at most the bound.
  • Choosing an MM that requires knowing the very value being approximated. Round up to a number you can justify.

Worked examples

Worked example

A sine approximation with M = 1

The third-degree Maclaurin polynomial for f(x)=sin⁡xf(x) = \sin x is P3(x)=x−x36P_3(x) = x - \frac{x^3}{6}. Use the Lagrange error bound to bound the error in approximating sin⁡(0.4)\sin(0.4) with P3(0.4)P_3(0.4).

  1. Identify the inputs: n=3n = 3, a=0a = 0, x=0.4x = 0.4, so the bound uses the fourth derivative.
  2. The fourth derivative of sin⁡x\sin x is sin⁡x\sin x, and ∣sin⁡z∣≤1|\sin z| \le 1 for all zz. Take M=1M = 1.
  3. Apply the bound: ∣sin⁡(0.4)−P3(0.4)∣≤14!(0.4)4=0.025624≈0.00107\left| \sin(0.4) - P_3(0.4) \right| \le \frac{1}{4!}(0.4)^4 = \frac{0.0256}{24} \approx 0.00107.
  4. A sharper bound is available. The Maclaurin polynomial for sine has no x4x^4 term, so P4(x)=P3(x)P_4(x) = P_3(x). Using n=4n = 4 with the fifth derivative cos⁡x\cos x and M=1M = 1: the error is at most 15!(0.4)5=0.01024120≈0.0000853\frac{1}{5!}(0.4)^5 = \frac{0.01024}{120} \approx 0.0000853.
  5. Check: P3(0.4)=0.4−0.0646≈0.389333P_3(0.4) = 0.4 - \frac{0.064}{6} \approx 0.389333 and sin⁡(0.4)≈0.389418\sin(0.4) \approx 0.389418. The actual error is about 0.0000850.000085, inside both bounds.

With n=3n = 3 the error is at most (0.4)424≈0.00107\frac{(0.4)^4}{24} \approx 0.00107. Treating the same polynomial as P4P_4 tightens this to about 0.00008530.0000853.

Worked example

An exponential with a rounded-up M

Use P2(x)=1+x+x22P_2(x) = 1 + x + \frac{x^2}{2}, the second-degree Maclaurin polynomial for f(x)=exf(x) = e^x, to approximate e0.5e^{0.5}, and bound the error.

  1. Compute the approximation: P2(0.5)=1+0.5+0.252=1.625P_2(0.5) = 1 + 0.5 + \frac{0.25}{2} = 1.625.
  2. Identify the inputs: n=2n = 2, a=0a = 0, x=0.5x = 0.5. The third derivative is f′′′(x)=exf'''(x) = e^x.
  3. Find MM on [0,0.5][0, 0.5]. Since exe^x is increasing, its maximum there is e0.5e^{0.5}. That is the number being approximated, so round up: e<4e < 4 gives e0.5<2e^{0.5} < 2. Take M=2M = 2.
  4. Apply the bound: ∣e0.5−P2(0.5)∣≤23!(0.5)3=2⋅0.1256=124≈0.0417\left| e^{0.5} - P_2(0.5) \right| \le \frac{2}{3!}(0.5)^3 = \frac{2 \cdot 0.125}{6} = \frac{1}{24} \approx 0.0417.
  5. Check: e0.5≈1.6487e^{0.5} \approx 1.6487, so the actual error is about 0.02370.0237, under the bound.

e0.5≈1.625e^{0.5} \approx 1.625 with error at most 124≈0.0417\frac{1}{24} \approx 0.0417.

Worked example

A derivative bound supplied by the problem

A function ff has derivatives of all orders, with f(2)=5f(2) = 5, f′(2)=−1f'(2) = -1 and f′′(2)=4f''(2) = 4. It is known that ∣f′′′(x)∣≤6\left| f'''(x) \right| \le 6 for 2≤x≤2.52 \le x \le 2.5. Approximate f(2.5)f(2.5) with the second-degree Taylor polynomial centered at x=2x = 2, and find an interval that must contain f(2.5)f(2.5).

  1. Build the polynomial: P2(x)=f(2)+f′(2)(x−2)+f′′(2)2!(x−2)2=5−(x−2)+2(x−2)2P_2(x) = f(2) + f'(2)(x - 2) + \frac{f''(2)}{2!}(x - 2)^2 = 5 - (x - 2) + 2(x - 2)^2.
  2. Evaluate at x=2.5x = 2.5, where x−2=0.5x - 2 = 0.5: P2(2.5)=5−0.5+2(0.25)=5P_2(2.5) = 5 - 0.5 + 2(0.25) = 5.
  3. Identify the inputs for the bound: n=2n = 2, ∣x−a∣=0.5|x - a| = 0.5, and M=6M = 6 from the given information.
  4. Apply the bound: ∣f(2.5)−P2(2.5)∣≤63!(0.5)3=0.125\left| f(2.5) - P_2(2.5) \right| \le \frac{6}{3!}(0.5)^3 = 0.125.
  5. Trap the true value: 5−0.125≤f(2.5)≤5+0.1255 - 0.125 \le f(2.5) \le 5 + 0.125.

f(2.5)≈5f(2.5) \approx 5 with error at most 0.1250.125, so 4.875≤f(2.5)≤5.1254.875 \le f(2.5) \le 5.125.

Frequently asked questions

How do I choose M in the Lagrange error bound?

Look at the derivative of order n+1n + 1 on the interval between the center and the xx-value. If it is a sine or cosine, use 11. If its absolute value is increasing or decreasing, use the value at the endpoint where it is largest. If the problem gives a bound, use that. You may always round up to a simpler number, because any MM at least as large as the true maximum is valid.

Is the Lagrange error bound the actual error?

No. It is an upper limit on the size of the error. The actual error is usually smaller, sometimes much smaller. In the e0.5e^{0.5} example above, the bound is about 0.04170.0417 and the actual error is about 0.02370.0237.

When can I use the alternating series error bound instead?

When the Taylor series at the given xx alternates in sign and its terms decrease in size to 00. Then the error of a partial sum is at most the size of the first omitted term. For a series that does not alternate at that xx, use the Lagrange bound.