-4
$\begingroup$

I am reading up on numerical integration and have trouble to really understand why or rather in what sense Simpson's rule is better than the Trapezoidal rule in general. There is a lot of stuff written on the subject but I have yet to find something that I find both convincing and I can understand. I hope that someone here is willing to help me.

I'll start by trying to state precisely what I want to understand.

The objective is to approximate the integral $$ I = \int_a^b f(x)dx $$ "as good as possible" while just knowing the values of $f(a)$, $f(\frac{a+b}{2})$, and $f(b)$. Nothing more is known of $f$. In the following, I'll use $m=(a+b)/2$ as a shorthand to lighten notation.

The basic trapezoidal rule says: $$ \int_a^b f(x)dx \approx (b-a)\left(\frac{1}{2}f(a)+\frac{1}{2}f(b)\right). $$ Simpson's rule says: $$ \int_a^b f(x)dx \approx (b-a)\left(\frac{1}{6}f(a)+\frac{4}{6}f(m)+\frac{1}{6}f(b)\right) = S. $$ I'll denote the expression by $S$.

It seems obvious to me that the second is better than the first, as it makes use of $f(m)$. I fail to be able to state this in any formal way but it seems self-evident to me that using information about $f$ is better than not using it.

So let's compare Simpon's rule to the composed trapezoidal rule that actually makes use of $f(m)$: this seems like a fair comparison. With this I mean, $$ \int_a^b f(x)dx \approx (m-a)\left(\frac{1}{2}f(a)+\frac{1}{2}f(m)) + (b-m)(\frac{1}{2}f(m)+\frac{1}{2}f(b)\right). $$ This can be simplified to: $$ \int_a^b f(x)dx \approx (b-a)\left(\frac{1}{4}f(a)+\frac{2}{4}f(m)+\frac{1}{4}f(b)\right) = T. $$ I'll denote the expression by $T$.

My question is why is $$ S=(b-a)\left(\frac{1}{6}f(a)+\frac{4}{6}f(m)+\frac{1}{6}f(b)\right) $$ "better" than $$ T=(b-a)\left(\frac{1}{4}f(a)+\frac{2}{4}f(m)+\frac{1}{4}f(b)\right) $$ in general?

My gut feeling is that we simply cannot tell in general what is better.

If we knew more stuff about $f$, then we could exploit that to tell what is better. For example, if we knew that $f$ was randomly selected according to some known distribution, then we could compare for example the expected values of $$ E_f\left[\Big|\int_a^b f(x)dx - S\Big|\right]\text{ vs }E_f\left[\Big|\int_a^b f(x)dx - T\Big|\right]. $$ I can give distributions where $S$ wins but I can also give some where $T$ wins. However, no literature that I have seen starts with defining a distribution for $f$.

I also believe that Simpson's rule will work better in experiments. However, I believe that this can be explained via the typical choices of $f$ in experiments. I believe that the distribution here favors Simpson's rule. Most experiments are either motivated by mathematicians cooking up functions or people modelling physics. Both mathematicians and physics love low degree polynomials. Obviously, Simpson's rule is better, if we know that $f$ is a polynomial. I therefore believe that in such a setting, experimental evidence will indeed state that Simpon's rule is better. However, that is no statement about the general case.

$\endgroup$
4
  • 7
    $\begingroup$ The error depends on the number $n$ of subdivisions as $1/n^2$ for the trapezoidal rule and as $1/n^4$ for Simpson's rule, so the latter converges more rapidly. For a given $n$ the trapezoidal rule may be more accurate than Simpson's rule if the integrand has a large fourth derivative, so indeed, for such a comparison you need to know the smoothness of the integrand. $\endgroup$ Commented Dec 4 at 9:57
  • $\begingroup$ I understand that we can consider asymptotics when we increase the number of samples. However, what about the case where $n$ is small? I think it is relevant to also have an answer here. The answer "use Simpon's rule because in a modified setting it can be better if we additionally assume that derivatives of $f$ are small" does not really convince me for the case $n=3$ to not use trapezoidal. $\endgroup$ Commented Dec 4 at 10:14
  • 2
    $\begingroup$ for small $n$ it all depends on the relative magnitude of $(b-a)^2 d^4f/dx^4$ and $d^2f/dx^2$; if the latter is smaller, use trapezoidal, otherwise use Simpson. $\endgroup$ Commented Dec 4 at 10:44
  • 2
    $\begingroup$ This MO website is for questions of math research. There's no research angle in this question. $\endgroup$ Commented Dec 4 at 10:52

2 Answers 2

3
$\begingroup$

This is a textbook question. The Simpson rule is exact (no error at all) when $f$ is a polynomial of degree $\le3$, while the trapezoidal rule is exact only for degree $\le1$ (affine functions). The error analysis involves a value of the next derivative. This is why the error is in terms of $(b-a)^5f^{(iv)}$ (Simpson) or $(b-a)^3f''$ (trapezoidal). If both $f''$ and $f^{(iv)}$ are under control, you see that Simpson's rule, combined with a decomposition of the domain of integration into $n$ equal sub-intervals, yields a much smaller error $\|f^{(iv)}\|_\infty O(\frac1{n^4})$, than the trapezoidal rule where it is only $\|f^{''}\|_\infty O(\frac1{n^2})$.

$\endgroup$
2
$\begingroup$

This question is likely to be closed as not research level.

In any case, the point is that one typically is not interested in numerically integrating functions about which nothing whatsoever is known (in which case they might not even be measurable, and the quadrature results would be quite meaningless!). Instead, one typically knows that the function $f$ to be integrated is e.g. the solution of some ODE, or is the output of a system known (or at least believed) to be modellable by some kind of functional relation between input and output, or something else of that kind, and in those cases one knows that $f\in C^k([a,b])$ for some given $k$, which means that one will generally benefit from using a quadrature rule with an error of order $O\left(\frac{\lVert f^{(k)}\rVert_\infty}{n^k}\right)$ over one with a lower order.

But in the rare case where you know a priori that $\lVert f^{(4)}\rVert_\infty\gg\lVert f''\rVert_\infty$ and can't afford to make $n$ large enough to compensate, then the trapezoidal rule might be better than Simpson's rule. Otherwise, Simpson always wins.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged .