12. Numerical Methods: Part II
Society for Industrial and Applied Mathematics eBooks · 2005
We now move on to MATLAB's capabilities for evaluating integrals and solving ordinary and partial differential equations. Most of the functions discussed in this chapter support mixed absolute/relative error tests, with tolerances AbsTol and RelTol, respectively. This means that they test whether an estimate err of some measure of the error in the vector x is small enough by testing whether, for all i, err(i) 0. A rough way of interpreting the mixed error test above is that err(i) is acceptably small if x(i) has as many correct digits as specified by RelTol or is smaller than AbsTol in absolute value. AbsTol can be a vector of absolute tolerances, in which case the test is err(i) <= max(AbsTol(i),RelTol*abs(x(i))) Several of the functions described in this chapter employ structures as input and output arguments, in order to group several related pieces of information in one variable. See Section 18.3 for full details of structures. The introduction of anonymous functions and nested functions in MATLAB 7 has had a big effect on the M-files in this chapter, because these types of function remove the need to pass problem parameters through argument lists. In all our examples we use the approach now recommended for handling problem parameters, but for ode45 and the Rössler system we show both the new way (Listing 12.1) and the old, MATLAB 6.5 and earlier, way (Listing 12.2) of doing things; this should be helpful for those wishing to read or convert code written in the earlier style. 12.1. Quadrature Quadrature is a synonym for numerical integration, the approximation of definite integrals MATLAB has two main functions for quadrature, quad and quadl. Both require a and b to be finite and the integrand to have no singularities on [a, b]. For infinite integrals and integrals with singularities a variety of approaches can be used in order to produce an integral that can be handled by quad and quadl; these include change of variable, integration by parts, and analytic treatment of the integral over part of the range. See numerical analysis textbooks for details, for example, [6, Sec. 5.6], [17, Sec. 7.4.3], and [101, Sec. 5.4].