## An analytical approach to computing step sizes for finite-difference derivatives

##### Abstract

Finite-difference methods for computing the derivative of a function with respect to an independent variable require knowledge of the perturbation step size for that variable. Although rules of thumb exist for determining the magnitude of the step size, their effectiveness diminishes for complicated functions or when numerically solving difficult optimization problems.
This dissertation investigates the problem of determining the step size that minimizes the total error associated with finite-difference derivative approximations. The total error is defined as the sum of errors from numerical sources (roundoff error) and mathematical approximations (truncation error). Several finite-difference approximations are considered, and expressions are derived for the errors associated with each approximation. Analysis of these errors leads to an algorithm that determines the optimal perturbation step size that minimizes the total error.
A benefit of this algorithm is that the computed optimal step size, when used with neighboring values of the independent variable, results in approximately the same magnitude of error in the derivative. This allows the same step size to be used for several successive iterations of the independent variable in an optimization loop. A range of independent variable values for which the optimal step size can safely remain constant is also computed.
In addition to roundoff and truncation errors within the finite-difference method, numerical errors within the actual function implementation are also considered. It is shown that the optimal step size can be used to compute an upper bound for these condition errors, without any prior knowledge of the function implementation. Knowledge of a function's condition error is of great assistance during the debugging stages of simulation design.
Although the fundamental analysis assumes a scalar function of a scalar independent variable, it is later extended to the general case of a vector function of a vector independent variable. Several numerical examples are shown, ranging from simple polynomial and trigonometric functions to complex trajectory optimization problems. In each example, the step size is computed using the algorithm developed herein, a rule-of-thumb method, and an alternative statistical algorithm, and the resulting finite-difference derivatives are compared to the true derivative where available.

##### Department

##### Description

text