Numerical Zoo · Integration

The narrow peak

A smooth integrand can still hide most of its area in a very small neighborhood.

Why numerical analysts keep this one around

The function exp(-400(x - 0.53)^2) is smooth everywhere, but almost all of its area sits near x = 0.53. A coarse integration scheme can therefore be formally appropriate and still spend most of its evaluations where almost nothing is happening.

This is a useful counterexample to the lazy distinction between smooth functions and difficult functions. Smoothness helps, but scale matters too. A feature can be perfectly smooth and still be too narrow for the current discretization.

The peak also makes adaptive thinking intuitive. Once we know where the function changes rapidly, we would rather spend evaluations there.

R setup

Start with the actual object.

f <- function(x) {
  exp(-400 * (x - 0.53)^2)
}

curve(f, from = 0, to = 1, n = 2000)

By hand first

Do enough arithmetic to see the trap.

1

At x = 0.53 the function is 1.

2

Move only 0.1 away and the exponent is -4, so the value has already dropped to about 0.018.

3

The interval is one unit wide, but the interesting part occupies only a small fraction of it.

What to look for

Now make it earn its reputation.

  • Start Simpson with very few panels and inspect whether any panel resolves the peak.
  • Compare 5-point and 20-point Gauss-Legendre rules.
  • Use Monte Carlo with different seeds and note how much the estimate depends on actually landing enough samples near the peak.
Keep this distinction:

The function is smooth. The problem is still hard at the scale we chose.