# 2.14  Numerical Integration: One Dimension

The fundamental theorem of calculus provides an explicit formula for the value of a definite integral. Let f be a real-valued function with antiderivative F, both defined on some open interval that contains points a and b. Then

[2.177]

If we lack an expression for the anti-derivative F, we cannot apply the fundamental theorem of calculus, but the integral can be valued using numerical methods of integration. In this section, we consider techniques based upon Riemann sums or generalizations of Riemann sums.

###### 2.14.1  Riemann Sums
Assume f :  →  is Riemann integrable. We want to evaluate the definite integral

[2.178]

for some a, b ∈ . With the method of Riemann sums we approximate the integral by dividing the interval [a,b] into m subintervals and approximating f with a constant function on each subinterval.

For any positive integer m, we define a partition p of [a,b] as m + 1 points x[0] < x[1] < … < x[m], where x[0] = a, x[m] = b and consecutive x[k] are spaced a constant length Δx = (ba)/m apart. We approximate our definite integral [2.178] with a Riemann sum:

[2.179]

###### 2.14.2 Example: Riemann Sums

As will be discussed in Chapter 3, a standard normal random variable has a probability of being between 0 and 1 that is given by the integral

[2.180]

There are more efficient ways this might be evaluated, but let’s approximate a solution with a Riemann sum. Setting m = 10, our subinterval length Δx is .10. Computations are presented in Exhibit 2.23.

Exhibit 2.23: Calculations to approximate [2.180] using a Riemann sum with m = 10.

We are approximating the integral by summing the areas of 10 rectangles. This is illustrated in Exhibit 2.24.

Exhibit 2.24: Graphical depiction of our Riemann sum calculations.

We can improve our approximation by valuing the Riemann sum [2.179] for a greater value m. Results for selected values of m are shown in Exhibit 2.25.

Exhibit 2.25: Approximation [2.179] or [2.180] improves as m increases.
###### 2.14.3 Trapezoidal Rule

The trapezoidal rule is a form of numerical integration that works in the same manner as Riemann sums. Instead of approximating f with a constant function on each subinterval of [a,b], it does so with a linear polynomial. The region under that linear polynomial is a trapezoid.

Exhibit 2.26: The trapezoidal rule employs trapezoids instead of the rectangles employed by Riemann sums.

On each sub-interval [x[k–1],x[k]], the trapezoid has area

[2.181]

Summing these areas across all the sub-intervals, we obtain an approximation for the definite integral:

[2.182]

[2.183]

###### 2.14.4 Example: Trapezoidal Rule

Let’s apply the trapezoidal rule to the same integral [2.180] to which we applied Riemann sums. We apply the trapezoidal rule [2.183] with m = 10, so our subinterval length Δx is .10. Our calculations are presented in Exhibit 2.27, and the work is illustrated graphically in Exhibit 2.28.

Exhibit 2.27: Calculations to approximate [2.180] using the trapezoidal rule with m = 10.
Exhibit 2.28: Graphical depiction of our trapezoidal rule calculations.

We can improve our approximation by increasing m. Results for selected values are shown in Exhibit 2.29. In this example, the trapezoidal rule achieves with m = 20 a result superior to that obtained by Riemann sums with m = 1000.

Exhibit 2.29: Example results are excellent for the trapezoidal rule, even with modest values of m.
###### 2.14.5 Simpson’s rule

Simposon’s rule is a third method of numerical integration. Instead of approximating f with constant functions or linear polynomials, it does so with quadratic polynomials. To evaluate an integral [2.178], we select a partition p of the interval [a,b] for some even number m. On each pair of consecutive subintervals, the area under f is approximated with the area under a quadratic polynomial.

Exhibit 2.30: The method of Riemann sums approximates f with constant functions on each subinterval. The trapezoidal rule approximates f with a linear polynomial on each subinterval. Simpson’s rule approximates f with a quadratic polynomial on each pair of consecutive subintervals.

Specifically, on each pair of sub-intervals, [x[k–1], x[k]] and [x[k], x[k+1]], the area under the indicated quadratic polynomial is found by integration to be

[2.184]

Summing across pairs of sub-intervals, we obtain the formula for Simpson’s rule:

[2.185]

###### 2.14.6 Example: Simpson’s Rule

We apply Simpson’s rule [2.185] to the same integral [2.180] as in our previous examples. Setting m = 10, our subinterval length Δx is .10. Our calculations are presented in Exhibit 2.31.

Exhibit 2.31: Calculations to approximate [2.188] using Simpson’s rule with m = 10.

With m = 10, we obtain the same result that we obtained for m = 1000 using the trapezoidal rule. Simpson’s rule does not always outperform so dramatically. In Section 3.16, we will consider an application for which the trapezoidal rule routinely outperforms Simpson’s rule.

###### Exercises
2.24

Evaluate the integral

[2.186]

four different ways:

1. analytically;
2. with a Riemann sum using m = 10;
3. with the trapezoidal rule using m = 10;
4. with Simpson’s rule using m = 10.