In the previous two chapters numerical derivatives have been used in the implementation of several code segments -- more specifically Newton’s method and nsolv(). The most powerful algorithms for handling nonlinear equations are to linearize and iterate on the linearized equations until a valid solution of the nonlinear equations is obtained. To do this one needs to be able to obtain the derivative of the nonlinear equations. Most authors shy away from recommending that this be done by numerical means and stress that if at all possible the derivatives be obtained analytically. This is usually not convenient and in some cases not possible as a set of equations may be generated only by a computer algorithm. The approach taken in this work is that numerical derivatives are acceptable if properly taken and this approach leads to greatly simplified algorithms as one then has to only specify the equations to be solved. This is in keeping with the principle that one should only have to define in a computer program a set of equations and any boundary conditions and the software should then take over and provide solutions.
Simple first order algorithms have been used in the previous chapters for numerical derivatives. These have been adequate for all the examples given in the previous chapters. In this chapter a much more in-depth look is undertaken of numerical derivatives and this provides the background needed to have confidence in the use of numerical derivatives in a wide range of nonlinear problems. In addition code segments are developed that can be used to calculate numerical derivatives with near machine precision for a wide range of functions.
A second major topic for this chapter is the closely related issue of numerically evaluation the value of an integral. Code segments are again developed that can integrate a large range of integrals with near machine precision.