01 / 20

Numerical
Integration

Approximate definite integrals when analytic methods fall short: master the trapezoidal rule and Simpson's rule for the IB HL exam.

IB Math AA HL

Why Numerical Integration?

Many integrals cannot be evaluated analytically. Functions like \( e^{-x^2} \), \( \frac{\sin x}{x} \), or data from experiments have no closed-form antiderivative. Numerical integration gives us concrete approximate values for \( \displaystyle\int_a^b f(x)\,dx \) by using finitely many sample points.

The Big Picture

Exact Integral
Find antiderivative \( F \) and compute \( F(b)-F(a) \). Not always possible.
Trapezoidal Rule
Connect data points with straight lines. Each strip is a trapezoid.
Simpson's Rule
Fit parabolas through consecutive triples. More accurate with the same number of points.

Visualising Trapezoids

\(x_0\)
\(x_1\)
\(x_2\)
\(x_3\)
\(x_4\)
\(h\)
\(y\)
\(x\)
\(y = f(x)\)

Each green strip is a trapezoid with parallel sides \( f(x_i) \) and \( f(x_{i+1}) \), and width \( h \). The area of each strip is \( \frac{h}{2}\bigl[f(x_i)+f(x_{i+1})\bigr] \).

The Trapezoidal Rule

$$ \int_a^b f(x)\,dx \approx \frac{h}{2}\Bigl[f(x_0) + 2f(x_1) + 2f(x_2) + \cdots + 2f(x_{n-1}) + f(x_n)\Bigr] $$

Simpson's Rule

$$ \int_a^b f(x)\,dx \approx \frac{h}{3}\Bigl[f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + \cdots + 4f(x_{n-1}) + f(x_n)\Bigr] $$

Parabolic Strips

\(x_0\)
\(x_1\)
\(x_2\)
\(x_3\)
\(x_4\)
×1
×4
×2
×4
×1
\(y = f(x)\)

Simpson's rule uses parabolic arcs (not straight lines) between consecutive triples. The coefficients 1, 4, 2, 4, 2, ..., 4, 1 arise from integrating each quadratic segment.

Trapezoidal vs Simpson's

Trapezoidal Simpson's
Approximation shape Straight line (degree 1) Parabola (degree 2)
Coefficients 1, 2, 2, ..., 2, 1 1, 4, 2, ..., 4, 1
Divisor \(\frac{h}{2}\) \(\frac{h}{3}\)
\(n\) requirement Any \(n \geq 1\) \(n\) must be even
Error order \(O(h^2)\) \(O(h^4)\)
Exact for polynomials up to degree 1 (linear) 3 (cubic)

Step-by-Step Method

1
Choose \( n \). For Simpson's, ensure \( n \) is even.
2
Compute \( h = \frac{b-a}{n} \) and list the nodes \( x_0, x_1, \ldots, x_n \).
3
Evaluate \( f(x_i) \) at every node. Organize in a table.
4
Apply the formula: multiply each \( f(x_i) \) by its coefficient, sum, then multiply by \( \frac{h}{2} \) (trap.) or \( \frac{h}{3} \) (Simpson's).
5
Interpret: state the approximation and note whether it is an overestimate or underestimate if curvature is known.

Example 1: Trapezoidal Rule

Estimate \( \displaystyle\int_0^1 e^{-x^2}\,dx \) using the trapezoidal rule with \( n = 4 \).

\( x_i \) \( f(x_i) = e^{-x_i^2} \) Coeff.
01.00001
0.250.93942
0.500.77882
0.750.56982
1.000.36791

Example 2: Simpson's Rule

Use the same data (\( n=4 \)) to estimate \( \displaystyle\int_0^1 e^{-x^2}\,dx \) with Simpson's rule.

\( x_i \) \( f(x_i) \) Coeff.
01.00001
0.250.93944
0.500.77882
0.750.56984
1.000.36791

Example 3: Data Table

A scientist measures a rate function \( r(t) \) at equal intervals. Estimate \( \displaystyle\int_0^6 r(t)\,dt \) using both rules (\( n = 6 \), \( h = 1 \)).

\( t \) 0123456
\( r(t) \) 2578643
Trapezoidal
\( \frac{1}{2}[2 + 2(5) + 2(7) + 2(8) + 2(6) + 2(4) + 3] = \) 32.5
Simpson's
\( \frac{1}{3}[2 + 4(5) + 2(7) + 4(8) + 2(6) + 4(4) + 3] = \) 33.0

Over or Under-estimate?

\(f(x)\) concave up
Chord lies above curve
Trapezoidal overestimates
Concave up (\( f'' > 0 \))
Trapezoidal rule overestimates: chords sit above the curve.
Concave down (\( f'' < 0 \))
Trapezoidal rule underestimates: chords sit below the curve.

Error Bounds

Trapezoidal Error
$$ |E_T| \leq \frac{(b-a)^3}{12n^2}\,\max_{[a,b]}|f''(x)| $$
Simpson's Error
$$ |E_S| \leq \frac{(b-a)^5}{180n^4}\,\max_{[a,b]}|f^{(4)}(x)| $$

Common Mistakes

✕ Wrong divisor
Using \( \frac{h}{3} \) for trapezoidal or \( \frac{h}{2} \) for Simpson's. Remember: trap = 2, Simp = 3.
✕ Odd \( n \) for Simpson's
Simpson's rule requires an even number of sub-intervals. \( n = 5 \) won't work.
✕ Coefficient errors
Giving the endpoints coefficient 2 or 4 instead of 1. Endpoints always get coefficient 1.

Question 1 of 5

Using the trapezoidal rule with \( n = 3 \) and \( h = 2 \), which expression approximates \( \displaystyle\int_0^6 f(x)\,dx \)?

Question 2 of 5

Simpson's rule requires that \( n \) (the number of sub-intervals) is:

Question 3 of 5

Given \( f(0)=1 \), \( f(1)=3 \), \( f(2)=2 \), what is the Simpson's rule estimate of \( \displaystyle\int_0^2 f(x)\,dx \) with \( n = 2 \)?

Question 4 of 5

If \( f \) is concave up on \([a,b]\), the trapezoidal rule will:

Question 5 of 5

Halving the step size \( h \) in Simpson's rule reduces the error by approximately a factor of: