# Numerical Integration

Mathematics I · Scientific Programming · https://tryals.app/learn/mathematics-i/numerical-integration

## Quadrature and Basic Rules

Many definite integrals lack an antiderivative, like the Gaussian $\int e^{-x^2} dx$. When the Fundamental Theorem fails, **numerical integration** (quadrature) approximates the area using function values.

| Method | Shape Used | Truncation Error | Key Feature |
| --- | --- | --- | --- |
| **Midpoint** | Rectangle | $\sim h^2$ per step | Crude baseline |
| **Trapezoidal** | **Trapezoid** | $\sim h^2$ global | Straight-line connects |
| **Simpson's** | **Parabola** | $\sim h^4$ global | Fits triples of points |

**Simpson's rule** fits a parabola through each point triple. Because parabolas hug curves tightly, halving $h$ cuts its error by sixteen. It is exact for polynomials up to degree three.

## Accuracy Limits and Pitfalls

The golden principle: **finer subdivisions** ($h$) and **higher-order rules** drive faster convergence.

**Common Pitfall:** Assuming more subdivisions always improve accuracy. Shrinking $h$ reduces **truncation error**, but summing millions of tiny terms allows **round-off error** to accumulate and eventually dominate the final result.

**The Solution:** Do not blindly shrink $h$ into the round-off zone. Instead, use a higher-order method like Simpson's rule to achieve high accuracy at a modest step size.

## Practice questions

6 of this lesson's 11 practice questions, with answers. The full set is in the app.

### 1. The exact value of the integral of x squared from 0 to 2 is 8/3. The trapezoidal estimate with two strips is 3. What is the absolute error of that estimate?

**Answer:** 0.3333 (within ±0.03)

**Why:** 3 - 2.667 = 0.333. Simpson's rule on the very same three function values gave zero error, which shows that accuracy came from the shape fitted, not from extra data.

Page: https://tryals.app/practice/mathematics-i/numerical-integration/the-exact-value-of-the-integral-of-x-squared-from-0-to-2-is-8-3-the

### 2. Order the steps of estimating an integral by the trapezoidal rule.

**Answer:**

1. Choose the number of strips and compute the step size
2. Evaluate the function at every grid point
3. Add the two end heights, each counted half
4. Add every interior height at full weight
5. Multiply the running total by the step size

**Why:** Choose the grid, sample, weight the ends at half and the interior at full, then scale by h. The weighting step is where the rule actually lives, everything else is bookkeeping.

Page: https://tryals.app/practice/mathematics-i/numerical-integration/order-the-steps-of-estimating-an-integral-by-the-trapezoidal-rule

### 3. Select every statement about numerical integration that is TRUE.

A. A higher-order rule reaches a given accuracy at a larger step size than a low-order one
B. Numerical integration is needed when no closed-form antiderivative exists
C. The trapezoidal rule fits a parabola to each strip
D. Simpson's rule is exact for a cubic polynomial
E. A finer subdivision always reduces the total error, without limit

**Answer:** A. A higher-order rule reaches a given accuracy at a larger step size than a low-order one; B. Numerical integration is needed when no closed-form antiderivative exists; D. Simpson's rule is exact for a cubic polynomial

**Why:** Simpson's is exact through degree three, quadrature exists precisely for integrals with no antiderivative, and higher order buys accuracy at coarser grids. Unlimited refinement is defeated by round-off, and it is Simpson's rule, not the trapezoidal, that uses parabolas.

Page: https://tryals.app/practice/mathematics-i/numerical-integration/select-every-statement-about-numerical-integration-that-is-true

### 4. Simpson's rule has error scaling like h⁴ against the trapezoidal rule's h². Why does fitting parabolas instead of straight lines gain two whole orders?

A. Because a parabola has three coefficients rather than two, so the error falls by the ratio 3/2.
B. Because parabolas can represent any smooth function exactly, so the only error is round-off.
C. Because Simpson's rule uses twice as many points, and doubling the points squares the accuracy.
D. Because a parabola matches one more derivative, so a term cancels.

**Answer:** D. Because a parabola matches one more derivative, so a term cancels.

**Why:** A parabola matches one more derivative than a trapezoid, killing the leading error term, and it kills more than expected, since Simpson's is exact for *cubics*, the odd error term cancelling between the two halves of each panel. Halving h reduces trapezoidal error by 4 and Simpson's by 16. The gain evaporates at kinks, where the extra derivatives do not exist.

Page: https://tryals.app/practice/mathematics-i/numerical-integration/simpsons-rule-has-error-scaling-like-h-against-the-trapezoidal

### 5. Simpson's rule is exact for cubics although it fits only parabolas. Why does it get a free degree of accuracy?

A. Because the error in fitting a cubic happens to be zero for all smooth functions
B. Because the rule uses three points, which determines a cubic uniquely
C. Because the cubic error term is odd about the panel's midpoint
D. Because every cubic can be written as a parabola over a short enough interval

**Answer:** C. Because the cubic error term is odd about the panel's midpoint

**Why:** The leftover cubic term is odd about the midpoint, so its contributions on the two halves cancel exactly. That symmetry is why the error scales like h⁴ rather than h³, halving the step cuts the error sixteenfold, and the extra order came free from the geometry rather than from fitting anything cleverer.

Page: https://tryals.app/practice/mathematics-i/numerical-integration/simpsons-rule-is-exact-for-cubics-although-it-fits-only-parabolas

### 6. Measured values of a function at x = 0, 1, 2, 3 are 1, 3, 5 and 9. Apply the trapezoidal rule with step size 1 to estimate the integral from 0 to 3.

**Answer:** 13

**Why:** The estimate is 1/2 + 3 + 5 + 9/2 = 13. The halved end weights are the whole content of the trapezoidal rule, and giving every height full weight instead is the standard slip, it would have given 18 here.

Page: https://tryals.app/practice/mathematics-i/numerical-integration/measured-values-of-a-function-at-x-0-1-2-3-are-1-3-5-and-9
