Understanding the Lagrange error bound calculator — concept and principle
This calculator bounds the error of a Taylor polynomial approximation with the Lagrange remainder. For sin x, cos x, eˣ or your own bound M, it gives the error bound at a point, the Taylor polynomial value, the true value, the actual error and the smallest degree that meets a tolerance. Use it for calculus homework on Taylor series and numerical approximation.
How it is calculated
f(x) = Pₙ(x) + Rₙ(x), with Rₙ(x) = f⁽ⁿ⁺¹⁾(c) ÷ (n + 1)! × (x − a)ⁿ⁺¹ for some c between a and x
Lagrange error bound: |Rₙ(x)| ≤ M × |x − a|ⁿ⁺¹ ÷ (n + 1)!
- M is the largest value of |f⁽ⁿ⁺¹⁾| between a and x. For sin x and cos x, M = 1.
- The smallest degree n with bound ≤ tolerance is found by trying n = 0, 1, 2, …
The principle
A Taylor polynomial matches a function's value and first n derivatives at the centre a. The error that remains behaves like the next term of the series, but with the derivative evaluated at some unknown point c. Since c is unknown, using the largest possible size of that derivative, M, gives a guaranteed upper limit. The factorial in the denominator grows quickly, which is why a few more terms usually shrink the error dramatically near the centre.
Worked example
Default inputs: f(x) = sin x, a = 0, x = 0.5, n = 3, M = 1, tolerance 0.0001.
- (n + 1)! = 4! = 24; |x − a|⁴ = 0.5⁴ = 0.0625; M used 1.
- Error bound = 1 × 0.0625 ÷ 24 = 0.00260417.
- Taylor polynomial P₃(0.5) = 0.5 − 0.5³ ÷ 6 = 0.4791666667.
- True value sin 0.5 = 0.4794255386; actual error = 0.0002589, well inside the bound.
- Smallest degree with bound ≤ 0.0001: 5 (bound 0.5⁶ ÷ 720 ≈ 0.0000217).
| Point x where you approximate | Error bound |Rₙ(x)| ≤ |
|---|---|
| 0.125 | 0.0000101725 |
| 0.25 | 0.00016276 |
| 0.375 | 0.000823975 |
| 0.5 | 0.00260417 |
| 0.625 | 0.00635783 |
| 0.75 | 0.0131836 |
| 1 | 0.0416667 |
How to read the result
The bound is a worst case. Here the actual error is about ten times smaller, because for sin x the degree-3 and degree-4 polynomials are the same (the x⁴ coefficient is 0). Use the bound to decide how many terms you need for a guaranteed accuracy, not to estimate the exact error.
Common mistakes
- Using the n-th derivative instead of the (n + 1)-th.
- Choosing M at the centre only, instead of the largest value on the whole interval.
- Forgetting the factorial.
- Applying the bound outside the interval where M was found.
Frequently asked questions
What is the Lagrange error bound?
|Rₙ(x)| ≤ M|x − a|ⁿ⁺¹ ÷ (n + 1)!, a guaranteed upper limit on a Taylor polynomial's error.
How do I choose M?
Take the largest absolute value of the (n + 1)-th derivative between a and x.
Why is the actual error smaller than the bound?
The bound assumes the worst possible derivative value; the true one is usually smaller.
Sources: OpenStax, Calculus Volume 2 (2016), §6.3 Taylor and Maclaurin Series