Omni calculator
lastUpdated:

Lagrange Error Bound Calculator

Table of contents

How to use the Lagrange error bound calculatorWhat is the Lagrange error bound?A short introduction to the Taylor seriesHow do I calculate the Lagrange error bound?Calculating the Lagrange error bound: an exampleFAQs

The Lagrange error bound calculator will help you determine the Lagrange error bound, the largest possible error arising from using the Taylor series to approximate a function. And what's more, this article will show you:

  • What the Lagrange error bound is;
  • How it relates to the Taylor remainder theorem;
  • The Lagrange error bound formula; and
  • A worked-out example of how to calculate the Lagrange error bound.

🙋 Looking for other calculators on number series? Why not give our harmonic series calculator a try?

How to use the Lagrange error bound calculator

The Lagrange error bound calculator is easy to use! Simply enter your Taylor series problem's values into their corresponding fields:

  1. Enter the number of terms from the Taylor series (also known as the resulting Taylor polynomial's degree) into n.
  2. Enter the xx-value at which you're evaluating the error, into x.
  3. Enter the polynomial's center in the field labelled a.
  4. Enter the maximum value of the (n+1)(n+1)-th derivative of the function you're approximating, f(x)f(x), into the field labelled M.

The Lagrange error bound, emaxe_\text{max}, will be presented at the bottom of the calculator.

Now, if you find yourself asking questions such as "What is the Taylor series?" or "What is the Lagrange error bound?", then read on!

What is the Lagrange error bound?

The Lagrange error bound is the upper bound on the error that results from approximating a function using the Taylor series. Using more terms from the series reduces the error, but it's rarely zero, and it's hard to calculate directly. The error bound tells us what the largest possible error is. The Lagrange error bound formula is derived from the Taylor remainder theorem.

💡 The Lagrange error bound can be seen as a margin of error for the Taylor series approximation. If you want to learn more about that topic, head over to our margin of error calculator.

A short introduction to the Taylor series

If we have some function ff, then we can perfectly replicate it using an infinite sum of terms, each expressed using a higher-order derivative of ff. This endless sum is called the Taylor series.

Let's clarify the above with a mathematical definition — any function ff can be replicated by this infinitely long summation:

f(x)= f(a)+f(a)1!(xa)+f(a)2!(xa)2+f(3)(a)3!(xa)3+,\scriptsize \begin{aligned} f(x) =&\ f(a) \\[.6em] & + \frac{f'(a)}{1!}(x-a) \\[1em] & + \frac{f''(a)}{2!}(x-a)^2 \\[1em] & + \frac{f^{(3)}(a)}{3!}(x-a)^3 \\[1em] & + \dots, \end{aligned}

where:

  • f(n)f^{(n)} is the nn-th derivative of the function ff; and
  • aa is any point of our choosing, as long as f(x)f(x) is infinitely differentiable at aa.

Below, you can see the Taylor series in action, as it approximates f(x)=exf(x) = e^x with more and more terms, i.e., as the value of nn becomes higher and higher:

The Taylor series of the exponential function, y=exp(x), with an increasing number of terms used.
Approximating f(x)=exf(x) = e^x with the Taylor series.

Isn't that amazing? With only a 5th-degree polynomial, we can already approximate exe^x to a high degree of accuracy.

However, we now see a problem: the Taylor series' definition is only true if we use an infinite number of terms. If we stop anywhere short of infinity — and as mortals, we must — then we'd only have approximated f(x)f(x) with the Taylor polynomial, Pn(x)P_n(x):

Pn(x)= f(a)+f(a)1!(xa)+f(a)2!(xa)2+...+f(n)(a)n!(xa)n\scriptsize \begin{aligned} P_n(x) =&\ f(a) \\[.6em] & + \frac{f'(a)}{1!}(x-a) \\[1em] & + \frac{f''(a)}{2!}(x-a)^2 \\[1em] & + ... \\[.6em] & + \frac{f^{(n)}(a)}{n!}(x-a)^n \end{aligned}

Because Pn(x)P_n(x) is just an approximation of f(x)f(x), there will be a remainder, Rn(x)R_n(x):

Rn(x)= f(x)Pn(x)= f(n+1)(a)(n+1)!(xa)n+1 +f(n+2)(a)(n+2)!(xa)n+2 +f(n+3)(a)(n+3)!(xa)n+3 +\scriptsize \begin{aligned} R_n(x) =&\ f(x) - P_n(x) \\[.6em] =&\ \frac{f^{(n+1)}(a)}{(n+1)!}(x-a)^{n+1} \\[1em] &\ + \frac{f^{(n+2)}(a)}{(n+2)!}(x-a)^{n+2} \\[1em] &\ + \frac{f^{(n+3)}(a)}{(n+3)!}(x-a)^{n+3} \\[1em] &\ + \dots \end{aligned}

What is the value of Rn(x)R_n(x)? We can't know for sure because there are countless terms to calculate. We do know that the more terms we include from the series (i.e., the higher the polynomial's degree, nn), the better we approximate f(x)f(x) with Pn(x)P_n(x), and the smaller that error will become.

Lucky for us, there is an upper bound on Rn(x)R_n(x), a worst-case-scenario estimate of the error. It's called the Lagrange error bound, and this calculator and text is all about finding it.

💡 Errors aren't desirable, but measuring them is the first step to fixing them! Try our relative error calculator to get started.

How do I calculate the Lagrange error bound?

The Lagrange error bound formula is as follows:

emax=M×xa(n+1)(n+1)!\scriptsize e_\text{max} = \frac { M \times \left\vert x-a \right\vert^{(n+1)} } { (n+1)! }

where:

  • emaxe_\text{max} — Lagrange error bound;
  • xx — Where we're determining the error between f(x)f(x) and Pn(x)P_n(x);
  • aa — Where the polynomial is centered;
  • nn — Number of terms from the Taylor series we're including, and thus the degree of the resulting polynomial; and
  • MM — Largest value of f(n+1)(z)\left\vert f^{(n+1)}(z) \right\vert for all zz between aa and xx:
M=max{f(n+1)(z):z[a,x]}\scriptsize \qquad M = \max\left\{ \left\vert f^{(n+1)}(z)\right\vert : z \in [a,x]\right\}

Using emaxe_\text{max}, we can place a bound on RnR_n:

Rn(x)emax\scriptsize \left\vert R_n(x) \right\vert \le e_\text{max}

which simply states that Rn(x)R_n(x) cannot be larger in magnitude than emaxe_\text{max}, thereby providing an upper bound on any error that might result from the approximation of f(x)f(x).

That's enough formulae — let's look at an example of the Lagrange error bound and how it's calculated.

Calculating the Lagrange error bound: an example

Let's find the error bound for the function sin(x)\sin(x) at π/3\pi/3 when approximated by a 4th-order Taylor polynomial centered around π/6\pi/6.

Right off the bat, we have some values ready to be plugged into our Lagrange error bound formula:

  • f(x)=sin(x)f(x) = \sin(x);
  • x=π/3x = \pi/3;
  • n=4n = 4; and
  • a=π/6a = \pi/6.

The hardest part will be determining MM, the largest value of the (n+1)=5(n+1) = 5th differential of f(x)f(x) within our interval [a,x]=[π/6,π/3][a, x] = [\pi/6, \pi/3]. Let's find it.

The higher-order differentials of sin(x)\sin(x) are given below:

Order

Differential

1

cos(x)\cos(x)

2

sin(x)-\sin(x)

3

cos(x)-\cos(x)

4

sin(x)\sin(x)

5

cos(x)\cos(x)

Great! f(5)(x)=cos(x)f^{(5)}(x) = \cos(x). Now we need to know what the biggest value of cos(x)\cos(x) can be at any point in the range [π/6,π/3][\pi/6, \pi/3]. We could use some fancy mathematics for this, but we can also reason that

  • cos(0)=1\cos(0) = 1;
  • cos(π/2)=0\cos(\pi/2) = 0; and
  • cos(x)\cos(x) is strictly descending over the range 0xπ/20 \le x \le \pi/2.

So, the largest value of cos(x)\cos(x) in our range of [π/6,π/3][\pi/6, \pi/3] should be closer to x=0x=0, and therefore M=cos(π/6)M = \cos(\pi/6).

Now, we have everything we need to determine emaxe_\text{max}:

emax= M×xa(n+1)(n+1)!= cos(π/6)×π/3π/6(4+1)(4+1)!= = 0.000284\scriptsize \begin{aligned} e_\text{max} =&\ \frac { M \times \left\vert x-a \right\vert^{(n+1)} } { (n+1)! } \\[1em] =&\ \frac { \cos(\pi/6) \times \left\vert \pi/3 - \pi/6 \right\vert^{(4+1)} } { (4+1)! } \\ =&\ \dots \\[.6em] =&\ 0.000284 \\ \end{aligned}

Thanks to this result, we know that our error cannot be greater than 0.000284. Let's see if that's true:

f(x)=sin(x)=sin(π/3)=0.866023\scriptsize f(x) = \sin(x) = \sin(\pi/3) = 0.866023
P4(x)= f(a)+f(a)1!(xa)1+...+f(4)(a)4!(xa)4= sin(π/6)+cos(π/6)1!(π/3π/6)1+sin(π/6)2!(π/3π/6)2+cos(π/6)3!(π/3π/6)3+sin(π/6)4!(π/3π/6)4= 0.865757\scriptsize \begin{aligned} P_4(x) =&\ f(a) \\[.6em] & + \frac{f'(a)}{1!}(x-a)^1 \\ & + ... \\ & + \frac{f^{(4)}(a)}{4!}(x-a)^4 \\[1.2em] =&\ \sin(\pi/6) \\[1em] & + \frac{\cos(\pi/6)}{1!}(\pi/3-\pi/6)^1 \\[.6em] & + \frac{-\sin(\pi/6)}{2!}(\pi/3-\pi/6)^2 \\[1em] & + \frac{-\cos(\pi/6)}{3!}(\pi/3-\pi/6)^3 \\[1em] & + \frac{\sin(\pi/6)}{4!}(\pi/3-\pi/6)^4 \\[1em] =&\ 0.865757 \end{aligned}
R4(x)=f(x)P4(x)=0.000266emax=0.000284\scriptsize \begin{aligned} R_4(x) &= \left\vert f(x) - P_4(x) \right\vert \\[.6em] &= 0.000266 \\[.6em] &\le e_\text{max} = 0.000284 \end{aligned}

The Lagrange error bound is correct! And what's more, if we took the same steps for other values of nn, we can see how the error bound decreases as we approximate f(x)f(x) better:

nn

emaxe_\text{max}

Rn(x)R_n(x)

11

0.1187120.118712

0.0874240.087424

22

0.0207190.020719

0.0188850.018885

33

0.0027120.002712

0.0018330.001833

44

0.0002840.000284

0.0002670.000267

55

2.4785051052.478505 \cdot 10^{-5}

1.6086691051.608669 \cdot 10^{-5}

66

1.8539171061.853917 \cdot 10^{-6}

1.7770341061.777034 \cdot 10^{-6}

77

1.2133861071.213386 \cdot 10^{-7}

7.6883561087.688356 \cdot 10^{-8}

88

7.0591951097.059195 \cdot 10^{-9}

6.8286751096.828675 \cdot 10^{-9}

99

3.69618610103.696186 \cdot 10^{-10}

2.30519710102.305197 \cdot 10^{-10}

1010

1.75938010111.759380 \cdot 10^{-11}

1.71203710111.712037 \cdot 10^{-11}

And there you have it. We've shown you how to calculate the Lagrange error bound — now it's your turn!

FAQs

What is the Lagrange error bound for f(x) = 1/(1-x) at x=0.1 with a 2nd-order Maclaurin series?

The Lagrange error bound is 0.0015. We can calculate it with the following steps:

  1. Find the values for a, x, and n:
    • a = 0 (since we're using the Maclaurin series);
    • x = 0; and
    • n = 2.
  2. Find the largest value of the (n+1)th derivative of f anywhere between a and x. For us, this is 9 — you can do the math to see why.
  3. Plug these values into the Lagrange error bound formula.

What is the Taylor remainder?

The Taylor remainder is the difference between the Taylor series approximation of a function and the actual function itself. Because the Taylor series is infinitely long, we cannot calculate it conclusively, and it will always remain an approximation of the original function. However, we can put an upper limit on the Taylor remainder, which is called the Lagrange error bound.

What is M in the Lagrange error bound?

M represents the largest magnitude value that the (n+1)th derivative of the function f can take on between points a and x when you're approximating the value of f at x with an nth degree Taylor polynomial centered at a.

Check out 10 similar sequences calculators 🔗
Arithmetic sequenceCollatz conjectureConvolution...7 more