# Error bounds

### For midpoint rule, trapezoidal rule and simpson's rule

Remember that midpoint rule, trapezoidal rule, and Simpson’s rule are all different ways to come up with an approximation for area under the curve. But how do we know how accurate our approximation is, in comparison to the exact area under the curve? We want to know whether an approximation is very good, and close to actual area, or if it’s a very bad approximation of actual area.

That’s where the error bound formulas come in. They tell us the maximum possible error in our approximations. So if the error bound is very large, we know that it’s possible that our approximation is bad, and far from the actual area. If the error bound is very small, we know that our approximation is pretty good, and close to the actual area.

The error bound formulas are

Midpoint rule error bound        ???\left|E_M\right|\le\frac{K(b-a)^3}{24n^2}???     ???\left|f''(x)\right|\le K???

Trapezoidal rule error bound    ???\left|E_T\right|\le\frac{K(b-a)^3}{12n^2}???      ???\left|f''(x)\right|\le K???

Simpson's rule error bound       ???\left|E_S\right|\le\frac{K(b-a)^5}{180n^4}???     ???\left|f^{(4)}(x)\right|\le K???

where

???E_M???, ???E_T???, and ???E_S??? are actual error for the midpoint, trapezoidal, and Simpson’s rule respectively

???\left|E_M\right|???, ???\left|E_T\right|???, and ???\left|E_S\right|??? are the absolute values of the actual errors, which you can also think of as the maximum possible error, or the maximum possible difference between your approximation of area and actual area

???[a,b]??? is the interval over which you’re finding area

???n??? is the number of subintervals you’re using to find area over the interval ???[a,b]???

???f''(x)??? is the second derivative of the given function ???f(x)???

???f^{(4)}(x)??? isthe fourth derivative of the given function ???f(x)???

You’ll want to use information from your problem to plug in for ???a???, ???b???, and ???n???, and you’re going to be solving the inequality for ???\left|E_M\right|???, ???\left|E_T\right|???, or ???\left|E_S\right|???. Which means the only value you really need to find is ???K???. Finding ???K??? is the only real tricky part when it comes to finding error bound.

"We want to know whether an approximation is very good, and close to actual area, or if it’s a very bad approximation of actual area."

Notice that for midpoint and trapezoidal rules, ???\left|f''(x)\right|\leq K???, and for Simpson’s rule ???\left|f^{(4)}(x)\right|\leq K???. This means that for midpoint and trapezoidal rules, ???K??? must always be greater than or equal to the second derivative of the given function, and that for Simpson’s rule, ???K??? must always be greater than or equal to the fourth derivative of the given function. In other words, what you’ll be trying to do is find the maximum possible value of the second derivative (for midpoint and trapezoidal rules) or fourth derivative (for Simpson’s rule) and use that value for ???K???.

## Let's walk through an error bounds example:

Find the error bound ???\left|E_S\right|??? if ???n=4???, and then find the number of subintervals ???n??? that will guarantee the area approximation is accurate within ???0.00001???.

???\int_0^1e^{x^2}\ dx???

We know that the interval we’re interested in is ???[a,b]=[0,1]??? and that ???n=4???, so plugging these values into the the Simpson’s rule error bound formula gives

???\left|E_S\right|\leq\frac{K(b-a)^5}{180n^4}???

???\left|E_S\right|\leq\frac{K(1-0)^5}{180(4)^4}???

???\left|E_S\right|\leq\frac{K}{46,080}???

To find a value for ???K???, we’ll need to use the condition that ???\left|f^{(4)}(x)\right|\leq K???, which means we need to find the fourth derivative of the given function ???f(x)=e^{x^2}???.

???f(x)=e^{x^2}???

???f'(x)=2xe^{x^2}???

???f''(x)=2e^{x^2}+4x^2e^{x^2}???

???f'''(x)=12xe^{x^2}+8x^3e^{x^2}???

???f^{(4)}(x)=12e^{x^2}+48x^2e^{x^2}+16x^4e^{x^2}???

Remember that the interval we’re interested in is ???[0,1]???. Therefore, we need to find the maximum value that this fourth derivative can attain over that interval. Since the fourth derivative is a polynomial function and every term is positive, we know it’s increasing throughout the interval, which means that the largest value it’ll attain is at ???x=1???.

At ???x=1???,

???f^{(4)}(1)=12e^{1^2}+48(1)^2e^{1^2}+16(1)^4e^{1^2}???

???f^{(4)}(1)=76e???

Since this is the largest value the fourth derivative will have during the interval, we’ll say ???K=76e???.

???\left|E_S\right|\leq\frac{76e}{46,080}???

???\left|E_S\right|\leq0.0045???

This tells us that the error will be no larger than about ???0.0045???, so if we used Simpson’s rule with ???n=4??? subintervals to approximate the area under the curve, we’d get a pretty accurate estimate of actual area.

To answer the second part of this question, we need to find the number of subintervals ???n??? that will guarantee an even more accurate estimation, one in which error is no greater than ???0.00001???. To do this, we’ll take the right side of the error bound formula, plug in for ???a???, ???b???, and ???K??? but leave ???n??? as-is, and set that less than or equal to ???0.00001???.

???\frac{76e(1-0)^5}{180n^4}\leq0.00001???

???76e\leq0.0018n^4???

???\frac{76e}{0.0018}\leq n^4???

???\sqrt[4]{\frac{76e}{0.0018}}\le n???

???18.41\leq n???

You can’t use ???18.41??? subintervals, you’d need to use either ???18??? subintervals, or ???19??? subintervals. But ???n??? must be greater than ???18.41??? in order to guarantee an approximation of area within ???0.00001??? of actual area, which means we’ll round up and say that ???n=19??? subintervals.

If we were doing this with a midpoint or trapezoidal rule problem, we could stop here. But with Simpson’s rule, remember that we always have to use an even number of subintervals. Which means that we actually have to round up to nearest even number, and use ???n=20??? subintervals in order to guarantee an area estimate within ???0.00001???.