8

We can approximate a definite integral, $\int_a^b f(x)dx$, using a variety of Riemann sums. If $T_n$ and $M_n$ are the nth sums using the trapezoid and midpoint (middle) sum methods and if the second derivative of $f$ is bounded on $[a, b]$ then does the following theorem imply that $M_n$ "tends to be more accurate" then $T_n$?

If $f''$ is continuous on $[a, b]$ and $|f''(x)| \leq K$, $\forall$ $x \in [a, b]$. Then,

$\left| \int_a^b f(x)dx - T_n \right| \leq K\frac{(b-a)^3}{12n^2}$

and

$\left| \int_a^b f(x)dx - M_n \right| \leq K\frac{(b-a)^3}{24n^2}$

For this question let, $E_{T_n} = \left| \int_a^b f(x)dx - T_n \right| $ and $E_{M_n} = \left| \int_a^b f(x)dx - M_n \right| $

The theorem is presented (without proof) in a calculus 2 book. It only really seems to imply that, we can with 100% certainly bound $E_{M_n}$ smaller than we can bound $E_{T_n}$. But, that says nothing about the actual values of $E_{T_n}$ or $E_{M_n}$.

So, isn't it possible to customize a function so that $E_{T_n} < E_{M_n}$ for a particular n? Could we even make a function so that $E_{T_n} < E_{M_n}$ $\forall n$?

futurebird
  • 6,308
  • For a particular $n$, absolutely: that's equivalent to doing it for $n=1$ and replicating the function across multiple intervals. Just consider any function satisfying $f(0)=f(1)=0$ and $\int_0^1 f(x), dx = 0$, but $f(1/2) \ne 0$. Then $E_T = 0$ but $E_M$ can be as large as you want (by rescaling $f$). – Erick Wong May 04 '16 at 08:40
  • This shows $T = 0$, not $E_T = 0$. – RRL May 05 '16 at 02:20
  • Although the Midpoint Rule is typically more accurate, it should be said that the Trapezoid Rule can be used to get $guaranteed$ upper and lower bounds for integrals of concave and convex functions respectively, which cannot be said for the Midpoint Rule. –  Oct 30 '17 at 15:56
  • @user123641 Shouldn't that be "guaranteed lower and upper", not "guaranteed upper and lower"? For concave and convex functions the sign of the error in the midpoint rule is guaranteed to be opposite the sign of the error in the midpoint rule, which means the latter give guaranteed upper and lower bounds in the cases where the former give guaranteed lower and upper bounds. – Will Orrick Aug 29 '23 at 11:39

1 Answers1

5

As you observed, the midpoint method is typically more accurate than the trapezoidal method. This is suggested by the composite error bounds, but they don't rule out the possibility that the trapezoidal method might be more accurate in some cases.

We can get a better understanding by examining the local errors for single-segment rules. Consider an interval $[a,b]$ and define interval length $h = b-a$ and midpoint $c = (a+b)/2.$ Note that $b-c = c-a = (b-a)/2 = h/2.$

The midpoint error is

$$E_M = f(c)h - \int_a^b f(x) \, dx = \int_a^b [f(c) - f(x)] \, dx.$$

Using a second-order Taylor approximation,

$$f(c) = f(x) + f'(x)(c-x) + \frac{1}{2} f''(\xi_x)(x-c)^2, $$

we see

$$E_M = -\int_a^b f'(x)(x-c) \, dx + \frac{1}{2}\int_a^b f''(\xi_x)(x-c)^2 \, dx.$$

Applying integration by parts to the first integral on the RHS we get

$$\int_a^b f'(x)(x-c) = \left.(x-c)f(x)\right|_a^b - \int_a^b f(x) \, dx = \frac{h}{2}[f(a) + f(b)] - \int_a^b f(x) \, dx .$$

Note that this result gives us the error $E_T$ for the trapezoidal method.

Hence,

$$E_M = -E_T + \frac{1}{2}\int_a^b f''(\xi_x)(x-c)^2 \, dx.$$

It is actually not that easy to find examples where $|E_T| < |E_M|$. Using the above result, we can surmise that this could happen when the midpoint method overestimates, $E_M > 0$, the trapezoidal method underestimates $E_T < 0,$ and we have high curvature in a small neighborhood of a point in the interval.

Here is a somewhat contrived example.

Consider the following function that meets those requirements. Note that the second derivative is piecewise continuous but bounded -- which does not degrade the composite $O(n^{-2})$ accuracy.

$$f(x) = \begin{cases} 0.25 + 0.75\exp(-200 x^2), &\mbox{if } -1 \leqslant x \leqslant 0 \\ 0.99 + 0.01 \cos(\pi x), &\mbox{if } \,\,\,\,\,\,\, 0 < x \leqslant 1 \end{cases}.$$

Then

$$\begin{align}\int_{-1}^1 f(x) \, dx &\approx 1.2870\\ M &\approx 2 \\ T &\approx 1.2300 \\ E_M &\approx 0.7130 \\ E_T &\approx 0.0570 \end{align}$$

RRL
  • 92,835
  • 7
  • 70
  • 142