# 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

*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*= (

*b*–

*a*)/

*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.

*m*= 10.

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

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.

*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.

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.

*m*= 10.

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.

*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.

*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.

*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

Evaluate the integral

[2.186]

four different ways:

- analytically;
- with a Riemann sum using
*m*= 10; - with the trapezoidal rule using
*m*= 10; - with Simpson’s rule using
*m*= 10.