Are midpoints always the best estimate for the area under the curve using a finite number of rectangles?

824 Views Asked by At

Are there any scenarios where midpoints would produce a result which is less accurate than left-endpoints or right endpoints?

If so, how do I recognize when each rule would apply the most accurate result?

2

There are 2 best solutions below

0
On

Obviously in the limit there is no such scenario for integrable functions, since the requirement for integrability is that all choices for test points converge to the same limit.

But it is easy to construct specific cases where the midpoint is inferior. For example, estimating the integral on $[0,1]$ using equal intervals of width $\frac 1{2^n}$ for some fixed $n$, where the integrand is $$f(t) = \begin{cases}1,& t = \dfrac{2k+1}{2^{n+1}}, k \in \Bbb N, k < 2^k\\0,&\text{otherwise}\end{cases}$$

So while you cannot force midpoints to always be worse than the endpoints, it is certainly the case you cannot expect any particular midpoint calculation to not be worse than the corresponding endpoint calculation. Or vice versa.

0
On

Suppose we are to estimate $\int_a^b \; f(t) \,\mathrm{d}t$ using a left-, mid-, or right- sum.

Let $M_1$ be the maximum of $|f'(x)|$ on $[a,b]$ and $M_2$ be the maximum of $|f''(x)|$ on $[a,b]$. Then (as you should know), the maximum error (absolute value of the difference between the value of the sum and the true value of the integral) in using a left- or right- sum of $n$ intervals (of width $\frac{b-a}{n}$ is \begin{align*} \text{left- and right-} && \text{error} &\leq \frac{M_1(b-a)^2}{2n} \\ \text{mid- } && \text{error} &\leq \frac{M_2(b-a)^3}{24n^2} \\ \end{align*} We can see that as $n$ gets large, eventually the mid-sum error should become less (and stay less) that the left- and right- sum errors. Let's show an example of this.

Let $\displaystyle f(x) = \frac{1}{10^4 x^2 +1}$ and $[a,b]=[0,3]$. Then, we can show $M_1 = \frac{75 \sqrt{3}}{2}$ and $M_2 = 20\,000$. With these, we can plot the upper bounds on the errors and see that eventually, the worst possible errors with the mid-sums will be less than the worst possible errors with the left- and right-sums (in this case).

Mathematica graphics

As we can see, for $n$ less than about $50$, the interval containing the value of the integral is narrower for left- and right- sums than for mid-sums. This reverses for $n$ greater than about $50$. But none of this reveals the detailed errors for particular choices for $n$, just conservative bounds for how far a sum can be from the true value of the integral. So let's study that.

Mathematica graphics

(The error bounds are shown in light gray.) Happily, we see that the actual errors are much less than the worst case bounds. Initially, left-sums are very inaccurate. (Expected, because this integrand is decreasing, rapidly for small $x$.) However, right- and mid-sums have the same initial accuracy, with mid-sums gradually improving faster than right-sums. Starting from $n$ a little less than $10^4$ and continuing to the right, the actual errors in the left- and right-sums exceed the error bound for the mid-sums, so the mid sums is guaranteed to be more accurate estimate of the integral than the left- and right-sums for large $n$.

The above is fairly generic behaviour for integrands that have a few monotonic regions on the interval of integration. What if this is not the case?

Consider $g(x) = sin(1/x)$ on $[10^{-4},1]$. It's a bit more work, but we can show that $M_1$ is a little less than $10^8$ and $M_2$ is a little less than $10^{16}$. (By a little less, I mean "less that one part per thousand".) Here, $n$ has to rise to around $10^7$ for the error bounds to match.

Mathematica graphics

Notice that the error is actually bounded. (The integrand is upper bounded by $1$ and lower bounded by $-1$, so the maximal possible error from a sum that samples the function is $2 \cdot (1-10^{-4})$, which is a bit less than $2$. So the error bounds are (very) pessimistic until $n$ is large-ish.

But the detailed behaviour is much more complicated.

Mathematica graphics

Which method has least error changes almost every time we increment $n$. (It may seem that the error hovers around $0.7$, but this is a coincidence among the small $n$ sums. Once $n$ is around $10^6$, the error starts to decrease -- this spacing of sample points is finally fine enough to see the individual oscillations in the function.)

So, yes, there are "scenarios where midpoints would produce a result which is less accurate than left-endpoints or right endpoints". In general, there is no way to "recognize when each rule would apply the most accurate result".

What can be done is this: Find the crossing $n$ for the two error estimates. Decide whether that value of $n$ is small enough to exceed or is too large for reasonable computation. If it is small, then use a mid-sum with larger $n$ (and possibly for a few values of $n$ to catch coincidences of large error). If it is not small, then use left- or right-sums (and possibly for a few values of $n$).