

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Numerical Integration This is a brief introduction to numerical integration, including Riemann sums and the trapezoid and Simpson’s rules. See also Stewart §5.2 and §7.7. The data is a table of values for a function, at evenly spaced points in an interval. The objective is to estimate the integral of the function over the interval. An example is given below.
Riemann sums: Integrals are defined as limits of Riemann sums so the most direct approximations are these sums. These are of the form
(∆x)
∑^ n
i=
f (xi)
where xi is a point in the ith^ subinterval. There are two known function values in each subinterval, and different “rules” for choosing one give different Riemann sums.
The choice of approximation depends on the application. For instance when ordering concrete to fill a form it is a serious problem not to get enough, but not serious to get a bit too much. Thus when estimating the volume needed by approximating an integral it would make sense to use the max sum. Note that the “midpoint rule” (Stewart §7.7) does not fit in here since it requires new evaluations. If it is possible to do new evaluations then there are better choices (i.e. that reduce error more) than the midpoints.
Trapezoid rule: This approximation uses the average of the two endpoint values on a subinterval. This can also be visualized as the area of a trapezoid. After adding we see all data points are used but interior ones have twice the weight: ∆x 2
(f (x 0 ) + 2 f (x 1 ) + · · · + 2 f (xn− 1 ) + f (xn))
There is only so much information that can be squeezed out of a data set. In particular the five approximations described above have some overlap:
Proposition: The trapezoid approximation is the average of the left and right endpoint sums, and also the average of the max and min sums.
Simpson’s rule: This approximation comes from quadratic approxima- tion, and the idea is as interesting as the rule. Think of the Riemann sum approximations as follows: on each subinterval choose a function value. This determines a constant function approximation on the subinterval. Putting these together gives a piecewise constant approximation to f. The Riemann sum is the exact integral of this approximate function. The trapezoid rule comes from a piecewise linear approximation: on each subinterval approxi- mate the function by the unique line that goes through the two data points at the endpoints. Then exactly integrate this approximate function. Simp- son’s rule takes this one step further: assume there are an even number of subintervals so they can be grouped in pairs. In each pair we have three data points, and there is a unique quadratic function that goes through these three points. Use this as the approximation to the function. Putting these together gives a piecewise quadratic approximation. Exactly integrate this approximate function. The outcome is ∆ 3 x times a weighted sum of all the function values. The weights are (1, 4 , 2 , 4 ,... , 2 , 4 , 1), so
∆x 3
(f (x 0 ) + 4 f (x 1 ) + 2 f (x 2 ) + · · · + 2 f (xn− 2 ) + 4 f (xn− 1 ) + f (xn))
Example
Suppose we are given data
x − 0. 9 − 0. 6 − 0. 3 0. 0 0. 3 0. 6 0. 9 f (x) 0. 5 − 1 − 0. 4. 3 0 −. 2 − 0. 1
and the objective is to approximate
− 0. 9 f^ (x)^ dx. There are six subintervals, so six terms in a Riemann sum, and ∆x = 0.3. The left endpoint Riemann sum is (0.3)[0.5 + (−1) + (− 0 .4) + 0.3 + 0 + (− 0 .2)] = − 0. 24