A-Level Mathematics – Chapter 9: Numerical Methods
Many equations and integrals arising in mathematics and science cannot be solved or evaluated exactly in closed form. Numerical methods provide systematic procedures for obtaining answers to any desired degree of accuracy. This chapter covers the three principal techniques at A-Level: locating roots by sign change, solving equations iteratively, the Newton-Raphson method, and approximating definite integrals.
Specification Note
All content in this chapter is required at both AS and A-Level. Newton-Raphson tends to appear more heavily at A2 but is examinable across all specifications. Always show sufficient iterations and check your answer against the required degree of accuracy.
9.1 Locating Roots
A root of the equation $f(x) = 0$ is a value $x = \alpha$ such that $f(\alpha) = 0$ — geometrically, a point where the graph $y = f(x)$ crosses the $x$-axis.
Sign Change Theorem
If $f$ is continuous on $[a, b]$ and $f(a)$ and $f(b)$ have opposite signs, then there is at least one root of $f(x) = 0$ in the interval $(a, b)$.
In practice: compute $f(a)$ and $f(b)$. If $f(a) \cdot f(b) < 0$, a root lies in $(a, b)$.
Figure 9.1 — The function $f(x) = x^3 - x - 1$. There is a root near $x \approx 1.32$ where the curve crosses the $x$-axis. $f(1) = -1 < 0$ and $f(2) = 5 > 0$ confirm a root in $(1, 2)$.
Interval Bisection
Once a root is located in $(a, b)$, interval bisection narrows the interval by repeatedly halving it. At each step, evaluate $f$ at the midpoint $m = \frac{a+b}{2}$ and replace whichever endpoint shares a sign with $f(m)$.
Example 9.1.1 — Verifying a Root by Sign Change
Show that $f(x) = x^3 - x - 1$ has a root in the interval $(1, 2)$.
$f(1) = 1 - 1 - 1 = -1 < 0$.
$f(2) = 8 - 2 - 1 = 5 > 0$.
Since $f(1) < 0$ and $f(2) > 0$, and $f$ is continuous, there is a root in $(1, 2)$ by the sign change theorem.
Example 9.1.2 — Interval Bisection
Use interval bisection to find the root of $f(x) = x^3 - x - 1$ to 1 decimal place.
Start: $a = 1$, $b = 2$. Midpoint $m = 1.5$: $f(1.5) = 3.375 - 1.5 - 1 = 0.875 > 0$. Root in $(1, 1.5)$.
Midpoint $m = 1.25$: $f(1.25) = 1.953 - 1.25 - 1 = -0.297 < 0$. Root in $(1.25, 1.5)$.
Midpoint $m = 1.375$: $f(1.375) \approx 2.600 - 1.375 - 1 = 0.225 > 0$. Root in $(1.25, 1.375)$.
Midpoint $m = 1.3125$: $f(1.3125) \approx -0.051 < 0$. Root in $(1.3125, 1.375)$.
The root is approximately $x \approx 1.3$ to 1 d.p.
Example 9.1.3 — Limitations of the Sign Change Method
Explain why the sign change method might fail to detect a root of $g(x) = (x-2)^2$ on $[1, 3]$.
$g(1) = 1 > 0$ and $g(3) = 1 > 0$. No sign change occurs, even though $x = 2$ is a root (where the curve touches the axis). This happens when the root is a repeated root — the curve touches but does not cross the $x$-axis.
Example 9.1.4 — Multiple Roots in an Interval
$f(x) = \sin(\pi x)$ has roots at every integer. Explain a scenario where a sign change on $[a, b]$ indicates one root but two roots actually exist.
If $a = 0.1$ and $b = 1.9$, then $f(0.1) > 0$ and $f(1.9) < 0$, suggesting one root. However, the roots at $x = 1$ is the only one in $(0.1, 1.9)$ crossed in a simple manner. But if $a = 0.1$ and $b = 2.9$, $f(0.1) > 0$ and $f(2.9) < 0$, two roots ($x=1$ and $x=2$) actually exist; the sign change tells us only that an odd number of roots lie in the interval. A graph or smaller sub-intervals are needed for certainty.
Exam Tip
When verifying a root in an interval, always state the sign of $f$ at each endpoint and explicitly invoke the sign change theorem. Showing a negative and positive value is not enough — you must state that because there is a sign change and $f$ is continuous, a root must lie in the interval. Also check there are no discontinuities (vertical asymptotes) inside the interval.
9.2 Iteration
The method of iteration (or fixed-point iteration) converts the equation $f(x) = 0$ into the form $x = g(x)$ and generates a sequence $x_{n+1} = g(x_n)$ from a starting value $x_0$. If the sequence converges, its limit is a fixed point of $g$ — i.e.\ a root of $f(x) = 0$.
Convergence Condition
The iterative sequence $x_{n+1} = g(x_n)$ converges to a root $\alpha$ if $|g'(\alpha)| < 1$.
If $|g'(\alpha)| > 1$, the sequence diverges. The same equation may give different rearrangements, some converging and some not.
Figure 9.2 — Cobweb diagram for $x_{n+1} = \cos x$ starting from $x_0 = 1$. The iteration converges to the fixed point where $y = \cos x$ intersects $y = x$ (the Dottie number, $\approx 0.739$). The spiral staircase pattern indicates convergence.
Iterative Method — Step by Step
To use the iterative method:
- Rearrange $f(x) = 0$ to the form $x = g(x)$ (there may be several valid rearrangements).
- Write the iterative formula $x_{n+1} = g(x_n)$.
- Choose a suitable starting value $x_0$ (typically from a sign change analysis).
- Compute successive iterates until the required accuracy is reached.
- Verify by checking $f$ changes sign around your answer.
Example 9.2.1 — Simple Iteration
Show that $x^3 - x - 1 = 0$ can be rearranged to $x = \sqrt[3]{x+1}$ and use this to find the root in $(1, 2)$ to 4 decimal places starting from $x_0 = 1$.
Rearrangement: $x^3 = x + 1 \Rightarrow x = (x+1)^{1/3}$. So $g(x) = (x+1)^{1/3}$.
| $n$ | $x_n$ |
|---|---|
| 0 | 1.000000 |
| 1 | 1.259921 |
| 2 | 1.312294 |
| 3 | 1.320695 |
| 4 | 1.322036 |
| 5 | 1.322249 |
| 6 | 1.322283 |
The sequence converges to $x \approx 1.3223$ (4 d.p.).
Example 9.2.2 — Divergent Rearrangement
Show that the rearrangement $x_{n+1} = x_n^3 - 1$ of the same equation diverges from $x_0 = 1.3$.
$x_1 = (1.3)^3 - 1 = 2.197 - 1 = 1.197$. $x_2 = (1.197)^3 - 1 \approx 0.713$. $x_3 = (0.713)^3 - 1 \approx -0.638$. The sequence does not converge to the root near $1.32$.
Check: $|g'(x)| = |3x^2|$. At $x \approx 1.32$, $|g'(1.32)| = 3(1.32)^2 \approx 5.23 > 1$, confirming divergence.
Example 9.2.3 — Choosing the Starting Value
The equation $e^x = 5 - 2x$ has a root in the interval $(0, 2)$. Use the rearrangement $x_{n+1} = \frac{1}{2}(5 - e^{x_n})$ with $x_0 = 1$ to find the root correct to 3 decimal places.
$x_1 = \frac{1}{2}(5 - e^1) = \frac{1}{2}(5 - 2.718) = 1.141$.
$x_2 = \frac{1}{2}(5 - e^{1.141}) = \frac{1}{2}(5 - 3.130) = 0.935$.
$x_3 \approx \frac{1}{2}(5 - 2.547) = 1.227$. Continuing: the sequence converges to $x \approx 1.052$.
Verify: $f(1.0515) < 0$ and $f(1.0525) > 0$. Root $\approx 1.052$ (3 d.p.).
Example 9.2.4 — Interpreting the Cobweb Diagram
Describe geometrically what happens in a cobweb diagram when $|g'(\alpha)| < 1$ and $g'(\alpha) > 0$.
The iterates spiral inward (staircase pattern): the vertical line to $y = g(x)$ and then the horizontal line to $y = x$ form a staircase that steps ever closer to the fixed point. If $g'(\alpha) < 0$ with $|g'(\alpha)| < 1$, the iterates oscillate around the root (cobweb pattern) but still converge.
9.3 Newton-Raphson Method
The Newton-Raphson method is a powerful technique that uses the tangent to the curve $y = f(x)$ at each iterate to obtain a better approximation to the root. It typically converges much faster than simple iteration.
Newton-Raphson Formula
$$x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}$$
This is derived by drawing the tangent to $y=f(x)$ at $(x_n, f(x_n))$ and finding where it cuts the $x$-axis. The method converges quadratically near a simple root — the number of correct decimal places roughly doubles with each iteration.
Failure: The method may fail if $f'(x_n) = 0$ (horizontal tangent) or if $x_0$ is chosen poorly (tangent points away from the root).
Example 9.3.1 — Newton-Raphson for a Cubic
Use Newton-Raphson with $x_0 = 1$ to find the root of $f(x) = x^3 - x - 1$ to 5 decimal places.
$f'(x) = 3x^2 - 1$.
| $n$ | $x_n$ | $f(x_n)$ | $f'(x_n)$ |
|---|---|---|---|
| 0 | 1.000000 | $-1.000$ | 2.000 |
| 1 | 1.500000 | 0.875 | 5.750 |
| 2 | 1.347826 | 0.101 | 4.449 |
| 3 | 1.325200 | 0.0021 | 4.270 |
| 4 | 1.324718 | $\approx 0$ | — |
Converges to $x \approx 1.32472$ (5 d.p.) in just 4 iterations, compared with over 10 for simple iteration.
Example 9.3.2 — Newton-Raphson for a Transcendental Equation
Use Newton-Raphson with $x_0 = 2$ to find the root of $f(x) = e^x - 4x$ in the interval $(2, 3)$.
$f'(x) = e^x - 4$.
$x_1 = 2 - \dfrac{e^2 - 8}{e^2 - 4} = 2 - \dfrac{7.389 - 8}{7.389 - 4} = 2 - \dfrac{-0.611}{3.389} = 2 + 0.180 = 2.180$.
$x_2 = 2.180 - \dfrac{e^{2.180} - 4(2.180)}{e^{2.180} - 4} \approx 2.180 - \dfrac{8.846 - 8.720}{8.846 - 4} = 2.180 - 0.026 = 2.154$.
Continuing: $x_3 \approx 2.153$. Root $\approx 2.153$.
Example 9.3.3 — Newton-Raphson Failure
Explain why Newton-Raphson may fail for $f(x) = x^{1/3}$ starting from $x_0 = 1$.
$f'(x) = \frac{1}{3}x^{-2/3}$. The formula gives $x_{n+1} = x_n - \frac{x_n^{1/3}}{\frac{1}{3}x_n^{-2/3}} = x_n - 3x_n = -2x_n$. Starting from $x_0 = 1$: $x_1 = -2$, $x_2 = 4$, $x_3 = -8$, $\ldots$ The method diverges, with each iterate moving further from the root $x=0$. This occurs because $f'(0) = 0$ (horizontal tangent at the root).
Example 9.3.4 — Comparing Methods
For $x^3 - 2x - 5 = 0$ near $x = 2$: compare one step of Newton-Raphson with one step of $x_{n+1} = \frac{x+5}{x^2}$, both starting from $x_0 = 2$.
Newton-Raphson: $f(2) = -1$, $f'(2) = 10$. $x_1 = 2 - \frac{-1}{10} = 2.1$.
Simple iteration: $x_1 = \frac{2+5}{4} = 1.75$. After further iterations this converges but more slowly. Newton-Raphson gives a closer estimate in fewer steps.
Example 9.3.5 — Deriving Newton-Raphson Geometrically
Derive the Newton-Raphson formula by finding where the tangent to $y = f(x)$ at $(x_n, f(x_n))$ meets the $x$-axis.
The tangent at $(x_n, f(x_n))$ has equation: $y - f(x_n) = f'(x_n)(x - x_n)$.
Setting $y = 0$: $-f(x_n) = f'(x_n)(x - x_n) \Rightarrow x = x_n - \dfrac{f(x_n)}{f'(x_n)}$. This $x$-intercept is defined to be $x_{n+1}$.
Exam Tip
When asked to "show that" Newton-Raphson gives the formula $x_{n+1} = \ldots$ for a specific equation, substitute $f(x)$ and $f'(x)$ into the formula and simplify algebraically. Do not just apply it numerically. Also, always verify your final answer satisfies the equation to the stated accuracy — show the sign change check.
9.4 Numerical Integration
When an integral cannot be evaluated in closed form, numerical methods provide accurate approximations. The two most common at A-Level are the trapezium rule and, on some specifications, Simpson's rule.
Trapezium Rule (Revision)
Dividing $[a, b]$ into $n$ strips of width $h = \frac{b-a}{n}$ with ordinates $y_0, y_1, \ldots, y_n$:
$$\int_a^b f(x)\,dx \approx \frac{h}{2}(y_0 + 2y_1 + 2y_2 + \cdots + 2y_{n-1} + y_n)$$Simpson's Rule
Simpson's rule uses pairs of strips (requiring an even number of strips, $n$) and fits a parabola through each group of three consecutive points:
Simpson's Rule Formula
With an even number of strips $n$ and $h = \frac{b-a}{n}$:
$$\int_a^b f(x)\,dx \approx \frac{h}{3}\bigl(y_0 + 4y_1 + 2y_2 + 4y_3 + 2y_4 + \cdots + 4y_{n-1} + y_n\bigr)$$
Pattern of coefficients: $1,\; 4,\; 2,\; 4,\; 2,\; \ldots,\; 4,\; 1$.
Simpson's rule is exact for polynomials of degree $\leq 3$, and is generally more accurate than the trapezium rule for smooth functions.
Figure 9.3 — Comparing the trapezium rule (orange strips) with the underlying curve $y = \sin x + 1$ on $[0, \pi]$. The exact value is $\pi + 2 \approx 5.142$; using 4 strips, the trapezium rule gives $\approx 5.056$ while Simpson's rule gives the exact answer in this case (since $\sin x + 1$ is well-approximated by polynomials over short intervals).
Example 9.4.1 — Trapezium Rule with 4 Strips
Estimate $\displaystyle\int_0^1 \frac{1}{1+x^2}\,dx$ using the trapezium rule with 4 strips.
$h = 0.25$. Ordinates:
| $x$ | $f(x) = \frac{1}{1+x^2}$ |
|---|---|
| 0 | 1.000000 |
| 0.25 | 0.941176 |
| 0.50 | 0.800000 |
| 0.75 | 0.640000 |
| 1.00 | 0.500000 |
$$\approx \frac{0.25}{2}\bigl(1 + 2(0.941176 + 0.8 + 0.64) + 0.5\bigr) = \frac{0.25}{2}(1 + 4.762352 + 0.5) = \frac{0.25}{2}(6.262352) \approx 0.783$$
Exact value: $\left[\arctan x\right]_0^1 = \frac{\pi}{4} \approx 0.7854$. Percentage error $\approx 0.3\%$.
Example 9.4.2 — Simpson's Rule with 4 Strips
Estimate $\displaystyle\int_0^1 \frac{1}{1+x^2}\,dx$ using Simpson's rule with 4 strips (same ordinates as above).
$$\approx \frac{h}{3}(y_0 + 4y_1 + 2y_2 + 4y_3 + y_4)$$
$$= \frac{0.25}{3}(1 + 4(0.941176) + 2(0.8) + 4(0.64) + 0.5)$$
$$= \frac{0.25}{3}(1 + 3.764706 + 1.6 + 2.56 + 0.5) = \frac{0.25}{3}(9.424706) \approx 0.78539$$
This matches $\frac{\pi}{4} = 0.78540$ to 5 significant figures — far more accurate than the trapezium rule with the same number of function evaluations.
Example 9.4.3 — Error Estimation for the Trapezium Rule
The trapezium rule with $n$ strips has a global error of order $O(h^2)$, where $h = \frac{b-a}{n}$. If doubling the number of strips reduces the error by a factor of approximately 4, estimate the error when the 4-strip and 8-strip estimates are known.
Let $T_4$ and $T_8$ be the 4-strip and 8-strip trapezium estimates, and let $I$ be the exact integral. Then $I - T_4 \approx 4(I - T_8)$, so $I \approx \frac{4T_8 - T_4}{3}$ (Richardson extrapolation — this gives Simpson's rule!).
Example 9.4.4 — Choosing Between Methods
Compare the trapezium rule and Simpson's rule in terms of accuracy, computational effort, and when each is preferred.
Trapezium rule — easy to apply, error $\approx O(h^2)$. Appropriate when the function has a simple shape or the specification only requires it. Overestimates for convex functions, underestimates for concave.
Simpson's rule — requires an even number of strips, error $\approx O(h^4)$ (much smaller). Preferred for smooth functions where high accuracy is needed with fewer evaluations. Exact for cubics and below.
Example 9.4.5 — Applying Simpson's Rule to a Trigonometric Integral
Use Simpson's rule with 6 strips to estimate $\displaystyle\int_0^{\pi} \sin x\,dx$.
$h = \frac{\pi}{6}$. Ordinates at $x = 0, \frac{\pi}{6}, \frac{\pi}{3}, \frac{\pi}{2}, \frac{2\pi}{3}, \frac{5\pi}{6}, \pi$:
$y_0 = 0$, $y_1 = 0.5$, $y_2 = \frac{\sqrt{3}}{2} \approx 0.8660$, $y_3 = 1$, $y_4 \approx 0.8660$, $y_5 = 0.5$, $y_6 = 0$.
$$\approx \frac{\pi/6}{3}(0 + 4(0.5) + 2(0.866) + 4(1) + 2(0.866) + 4(0.5) + 0) = \frac{\pi}{18}(0 + 2 + 1.732 + 4 + 1.732 + 2 + 0) = \frac{\pi}{18}(11.464) \approx 2.0000$$
Exact value is 2. Simpson's rule gives the exact answer here due to the symmetry and smoothness of $\sin x$.
Exam Tip
For the trapezium rule, lay out your ordinates in a clear table with full working. The two most common errors are: using the wrong number of strips (confusing $n$ strips with $n+1$ ordinates) and forgetting to multiply the middle terms by 2. For Simpson's rule, the middle terms alternate as $4, 2, 4, 2, \ldots, 4$ — the pattern always ends in $4$ just before the final term.
Practice Problems
Problem 1
Show that $f(x) = x^4 - x - 3$ has a root in the interval $(1, 2)$, and use interval bisection twice to narrow the interval.
Show solution
Midpoint $m = 1.5$: $f(1.5) = 5.0625 - 1.5 - 3 = 0.5625 > 0$. Root in $(1, 1.5)$.
Midpoint $m = 1.25$: $f(1.25) = 2.441 - 1.25 - 3 = -1.809 < 0$. Root in $(1.25, 1.5)$.
Problem 2
The equation $x^3 + 2x = 6$ has one real root. Show it lies in $(1, 2)$, and rearrange to the form $x_{n+1} = \sqrt[3]{6 - 2x_n}$. Use this to find the root to 3 d.p. starting from $x_0 = 1.5$.
Show solution
Rearrangement: $x^3 = 6 - 2x \Rightarrow x = (6-2x)^{1/3}$.
$x_1 = (6 - 3)^{1/3} = 3^{1/3} \approx 1.4422$.
$x_2 = (6 - 2.8845)^{1/3} = 3.1155^{1/3} \approx 1.4619$.
$x_3 \approx (6 - 2.9238)^{1/3} \approx 1.4555$.
Continuing: converges to $x \approx 1.453$ (3 d.p.).
Problem 3
For $f(x) = x^2 - 5$, apply Newton-Raphson with $x_0 = 2$ to find $\sqrt{5}$ to 6 decimal places. How many iterations are needed?
Show solution
$x_0 = 2$; $x_1 = \frac{4+5}{4} = 2.25$; $x_2 = \frac{5.0625+5}{4.5} = \frac{10.0625}{4.5} \approx 2.236111$;
$x_3 \approx 2.236068$; $x_4 = 2.236068$. Converges in 4 iterations to $\sqrt{5} \approx 2.236068$.
Problem 4
A student applies Newton-Raphson to $f(x) = \cos x - x$ starting from $x_0 = 0$. Find $x_1$, $x_2$ and comment on the convergence.
Show solution
$x_1 = 0 - \frac{\cos 0 - 0}{-\sin 0 - 1} = 0 - \frac{1}{-1} = 1$.
$x_2 = 1 - \frac{\cos 1 - 1}{-\sin 1 - 1} = 1 - \frac{0.5403 - 1}{-0.8415 - 1} = 1 - \frac{-0.4597}{-1.8415} \approx 1 - 0.2496 = 0.7504$.
$x_3 \approx 0.7391$. Converges to the fixed point of $\cos x$, the Dottie number $\approx 0.7391$.
Problem 5
The equation $2\ln x = 5 - x$ has a root near $x = 3.5$. Show the root lies in $(3, 4)$ and apply Newton-Raphson once from $x_0 = 3.5$.
Show solution
$g(4) = 2\ln 4 - 1 = 2(1.386) - 1 = 1.773 > 0$. Both positive? Try $f(x) = 2\ln x + x - 5$: $f(3) = 2.197 + 3 - 5 = 0.197 > 0$ and $f(2) = 2\ln 2 + 2 - 5 = 1.386 - 3 = -1.614 < 0$. Root in $(2, 3)$.
NR from $x_0 = 2.5$: $f'(x) = 2/x + 1$; $f(2.5) = 2\ln 2.5 - 2.5 = 1.833 - 2.5 = -0.667$; $f'(2.5) = 0.8 + 1 = 1.8$; $x_1 = 2.5 + 0.371 = 2.871$.
Problem 6
Use the trapezium rule with 5 ordinates (4 strips) to estimate $\displaystyle\int_1^3 \sqrt{1+x^2}\,dx$. State whether your estimate is an overestimate or underestimate, giving a reason.
Show solution
$$\approx \frac{0.5}{2}(1.4142 + 2(1.8028+2.2361+2.6926) + 3.1623) = 0.25(1.4142 + 13.4630 + 3.1623) = 0.25(18.0395) \approx 4.510$$
Since $f''(x) > 0$ for $\sqrt{1+x^2}$ (the function is convex), the trapezium rule is an overestimate.
Problem 7
Explain why the sign change method fails to detect the roots of $h(x) = \frac{1}{x-2}$ on the interval $[1, 3]$, and describe the pitfall.
Show solution
Problem 8
Use Simpson's rule with 4 strips to estimate $\displaystyle\int_0^2 e^{x^2/2}\,dx$.
Show solution
$$\approx \frac{0.5}{3}(1 + 4(1.1331) + 2(1.6487) + 4(3.0802) + 7.3891)$$ $$= \frac{0.5}{3}(1 + 4.5324 + 3.2974 + 12.3208 + 7.3891) = \frac{0.5}{3}(28.5397) \approx 4.757$$
Problem 9
Show that the iterative formula $x_{n+1} = \frac{2}{3}\left(x_n + \frac{3}{x_n^2}\right)$ can be used to solve $x^3 = 3$, and find $\sqrt[3]{3}$ to 4 significant figures starting from $x_0 = 1.5$.
Show solution
The correct formula for $x^3 = 3$ is: rearrange Newton-Raphson for $f(x) = x^3 - 3$: $x_{n+1} = x_n - \frac{x_n^3-3}{3x_n^2} = \frac{2x_n}{3} + \frac{1}{x_n^2}$.
$x_0 = 1.5$; $x_1 = 1 + \frac{1}{2.25} = 1 + 0.444 = 1.444$; $x_2 = 0.963 + 0.480 = 1.443$; $x_3 = 1.4422$. So $\sqrt[3]{3} \approx 1.442$ (4 s.f.).
Problem 10
The trapezium rule with 2 strips gives an estimate $T_2$ and with 4 strips gives $T_4$ for the same integral. Using the fact that the trapezium rule error is $O(h^2)$, show that the improved estimate $\frac{4T_4 - T_2}{3}$ is equivalent to Simpson's rule.
Show solution
$T_2 = I + K(h/1)^2 \cdot (\text{factor})$ with $h = (b-a)/2$, $T_4 = I + K(h/2)^2 \cdot (\text{factor})$.
More precisely, if $T(h)$ denotes the trapezium estimate with step $h$: $T(h) \approx I + Ch^2$. Then $T(h/2) \approx I + C(h/2)^2 = I + Ch^2/4$.
Richardson: $\frac{4T(h/2) - T(h)}{3} = \frac{4(I + Ch^2/4) - (I + Ch^2)}{3} = \frac{4I + Ch^2 - I - Ch^2}{3} = \frac{3I}{3} = I$.
Expanding the trapezium sums explicitly shows this combination equals $\frac{h}{3}(y_0 + 4y_1 + 2y_2 + 4y_3 + y_4)$, i.e.\ Simpson's rule.