The use of finite difference methods for approximating derivatives has historic roots (recall the definition of the derivative from calculus). The need for derivatives is fundamental in calculations solving nonlinear problems, as the use of Newton-like approaches is central to the solution of such problems. Specific examples occur in initial and boundary value ordinary differential equations (ODEs) and nonlinear optimization. While the finite difference approach to approximating derivatives is commonly used, there are more accurate and efficient alternatives embodied in the use of automatic differentiation. This paper provides an alternative that can be used for approximating the first derivative with an accuracy and speed comparable to the automated differentiation approach. Additionally, this is accomplished via the use of a package called PMAD, developed for the MATLAB problem solving environment (PSE).
The approach is based on the use of complex step differentiation (CSD), which allows for the use of very small step sizes; thus, very accurate first derivative approaches are obtained. While the use of centered finite difference approximation yields the same accuracy as CSD differencing [1], for the centered difference approach, using a small step size h, relative to the independent variable x, may lead to loss of accuracy. In a complex case, this does not occur since the step size is done in an imaginary direction, and even for a small h, the effect of the step is not lost. This is the key observation that enables highly accurate approximation of the first derivative of the function to be obtained.
The paper provides a thorough development of the history, approach, and software in the package. Historical ties to automatic differentiation and the relative strengths and limitations of this approach and PMAD are detailed. The package allows for two options: the fast option and an object-oriented (OO) approach. The fast approach is not as fast as the OO approach, and is in fact comparable in speed to the finite difference approach. However, the OO approach has an interface that is easier to use. The paper provides considerable detail on these approaches. It includes examples from the areas obtaining the Jacobian for boundary value ODEs and for solving a system of nonlinear equations. The software is available from Shampine’s Web site.
The only error in the paper is a slight mistyping of the URL (which should be: faculty.smu.edu/shampine/current.html).