A Lagrange error bound calculator tells you how far a Taylor polynomial can be from the function it approximates. Enter the degree n, the center a, the point x and a bound M for the next derivative, and it gives the bound M|x − a|ⁿ⁺¹/(n + 1)!. For sin x, cos x and eˣ it works out M for you and compares the bound with the actual error. You can also ask for the smallest degree that guarantees a given tolerance. The formula follows the Wikipedia page on Taylor's theorem, and the work is done in your browser.
How to use the Lagrange error bound calculator
- Choose what you want: the error bound, or the smallest degree for a tolerance.
- Choose the function, or enter M for another function.
- Enter the degree n, the center a and the point x.
- Press Calculate.
The Lagrange form of the remainder
Taylor's theorem says that a function f can be approximated near a point a by a polynomial of degree n, and that the difference, the remainder, has a precise form. The Wikipedia page states the Lagrange form: R_n(x) = f⁽ⁿ⁺¹⁾(ξ)/(n + 1)! times (x − a)ⁿ⁺¹, for some number ξ between a and x. The function must have n + 1 derivatives on the interval. We cannot know ξ exactly, but if the (n + 1)th derivative is at most M in size on the interval, the page gives the bound |R_n(x)| ≤ M|x − a|ⁿ⁺¹/(n + 1)!.
A worked example with eˣ
Approximate e = e¹ by the Taylor polynomial of degree 3 for eˣ at a = 0. The polynomial is 1 + x + x²/2 + x³/6, which at x = 1 is 2.66667. Every derivative of eˣ is eˣ, which on the interval from 0 to 1 is at most e, so M = e, about 2.71828. The bound is e × 1⁴ / 4!, which is 0.113262. The actual error is e − 2.66667, which is 0.0516152, and it is within the bound, as the theorem guarantees. The calculator shows all of these.
A worked example with sin x
For sin x at a = 0 and x = 0.5, with n = 3, every derivative of sine is plus or minus sine or cosine, so M = 1. The bound is 0.5⁴/24, which is 0.00260417. The polynomial x − x³/6 gives 0.479167 and the actual sine is 0.479426, so the actual error is 0.000259, about ten times smaller than the bound. The bound is a safe guarantee, but not a tight estimate.
Choosing M
M is the hardest part of a Lagrange error bound problem. For sine and cosine, every derivative is bounded by 1, so M = 1. For eˣ on an interval, the largest derivative is at the right end of the interval, e to the power of the larger of a and x. For other functions, you must find the largest absolute value of the (n + 1)th derivative on the interval, or any number that is certainly at least as large. A larger M gives a larger, but still valid, bound. The calculator accepts your own M for such functions.
How many terms do you need?
To guarantee an error below a tolerance, find the smallest n for which the bound is at most that tolerance. For sin x at x = 1 with a tolerance of 0.000001, M is 1, and 1/(n + 1)! must be at most 10⁻⁶. Since 9! is 362,880 and 10! is 3,628,800, n + 1 must be 10, so n = 9. For eˣ at x = 1 with a tolerance of 0.001, n = 6 is the first that works. The calculator searches degrees from 0 to 100 and reports the first one that meets the tolerance.
A worked example with another function
For ln(1 + x), centered at 0, with x = 0.5 and n = 3, the fourth derivative is −6 divided by (1 + x)⁴. Its size is at most 6 on the interval from 0 to 0.5, so M = 6. The bound is 6 × 0.5⁴/24, which is 0.015625. The polynomial x − x²/2 + x³/3 gives 0.416667 at 0.5, while ln 1.5 is 0.405465, so the actual error is 0.0112, within the bound. Choose another function in the calculator and enter 6 for M to see this.
A worked example with cosine
Approximate cos 0.3 by the polynomial of degree 2 at a = 0, which is 1 − x²/2, or 0.955. Here M = 1, and the bound is 0.3³/3!, which is 0.0045. The actual cosine is 0.955336, so the actual error is 0.000336, about thirteen times smaller than the bound. The calculator shows this comparison for sin x, cos x and eˣ, so you can see how conservative the bound is.
Reading the results
The first result is the bound, the largest error that the theorem allows. Below it, the calculator repeats the value of M that it used, the distance from the center and the factorial. For sin x, cos x and eˣ, it then gives the value of the Taylor polynomial, the exact value, the actual error and a yes or no on whether the actual error is within the bound. A no would mean that an input was entered wrongly, since the theorem guarantees a yes.
Typing tips
The degree n must be a whole number. The center and the point can be any numbers, positive or negative. For the other-function option, make sure that M is not smaller than the true maximum of the (n + 1)th derivative.
Common mistakes
- Using the nth derivative. The bound uses the (n + 1)th derivative.
- Taking M at the center only. It must cover the whole interval.
- Forgetting the factorial. The denominator is (n + 1)!, not n!.
- Treating the bound as the error. The real error is usually smaller.
- Mixing up the degree and the number of terms. Degree n has n + 1 terms.
What next
Use this often? Add Lagrange Err to your Home screen.
Frequently asked questions
What is a Lagrange error bound calculator?
A tool that finds the largest possible error of a Taylor polynomial: M·|x − a|ⁿ⁺¹/(n + 1)!.
What is the Lagrange error bound formula?
|R_n(x)| ≤ M·|x − a|ⁿ⁺¹ / (n + 1)!, where M is a bound for |f⁽ⁿ⁺¹⁾| between a and x.
How do I choose M?
Find the largest absolute value of the (n + 1)th derivative on the interval. For sin and cos, M = 1. For eˣ, M = e raised to the larger of a and x.
What is the bound for e¹ with a degree 3 polynomial at 0?
e/24 ≈ 0.113262. The actual error is about 0.0516152.
How many terms do I need for a given accuracy?
The smallest n for which the bound is at most the tolerance. For sin 1 within 10⁻⁶, n = 9.
Sources
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.