Numerical Analysis Using MATLAB and Spreadsheets

This chapter is an introduction to numerical methods for integrating functions which are very difficult or impossible to integrate using analytical means. We will discuss the trapezoidal rule that computes a function f( x) with a set of linear functions, and Simpson's rule that computes a function f( x) with a set of quadratic functions.
Consider the function y = f( x) for the interval a ? x ? b, shown in Figure 10.1.
To evaluate the definite integral ? b a f( x) dx, we divide the interval a ? x ? b into n subintervals each of length
. Then, the number of points between x 0 = a and x n = b is x 1 = a + ? x, x 2 = a + 2? x, ... xn ? 1 = a + ( n ? 1) ? x. Therefore, the integral from a to b is the sum of the integrals from a to x 1, from x 1 to x 2, and so on, and finally from x n ? 1 to b. The total area is
The integral over the first subinterval, can now be approximated by the area of the trapezoid aP 0