Numerical Methods in Engineering with MATLAB

Compute
(x) dx, where (x) is a given function
Numerical integration, also known as quadrature, is intrinsically a much more accurate procedure than numerical differentiation. Quadrature approximates the definite integral
by the sum
where the nodal abscissas x i and weights A i depend on the particular rule used for the quadrature. All rules of quadrature are derived from polynomial interpolation of the integrand. Therefore, they work best if ( x) can be approximated by a polynomial.
Methods of numerical integration can be divided into two groups: Newton-Cotes formulas and Gaussian quadrature. Newton-Cotes formulas are characterized by equally spaced abscissas, and include well-known methods such as the trapezoidal rule and Simpson s rule. They are most useful if ( x) has already been computed at equal intervals, or can be computed at low cost. Since Newton-Cotes formulas are based on local interpolation, they require only a piecewise fit to a polynomial.
In Gaussian quadrature the locations of the abscissas are chosen to yield the best possible accuracy. Because Gaussian quadrature requires fewer evaluations of the integrand for a given level of precision, it is popular in cases where ( x) is expensive to evaluate. Another advantage of Gaussian quadrature is its ability to handle integrable singularities, enabling us to evaluate expressions such as
provided that g(x) is a well-behaved function.
Consider the definite...