TOPICS
Search

Complex Step Differentiation


Complex step differentiation is a method of numerical differentiation that estimates a derivative using a function value at a complex number. Let x be real and let f(z) be analytic near x, with real values on a real neighborhood of x. For sufficiently small real h, its Taylor series gives

 f(x+ih)=sum_(k=0)^infty((ih)^k)/(k!)f^((k))(x),

where i is the imaginary unit. Taking the imaginary part and dividing by h!=0 yields

 (Im[f(x+ih)])/h=f^'(x)-(h^2)/6f^(''')(x)+O(h^4).

Here O denotes big-O notation. Thus Im[f(x+ih)]/h estimates f^'(x) with error O(h^2) (Squire and Trapp 1998).

The approximation avoids subtracting nearly equal real function values, which can cause roundoff error in real finite difference formulas. It requires an analytic function with the stated real-valued restriction and numerical evaluation that preserves the small imaginary perturbation. It does not eliminate errors in the function evaluation or underflow.

Martins et al. (2003) describe implementations in sensitivity analysis. Extensions approximate Fréchet derivatives of matrix functions (Al-Mohy and Higham 2010) and derivatives on matrix Lie groups (Cossette et al. 2020). A quaternionic step allows differentiation of holomorphic functions at complex arguments (Roelfs et al. 2021).


See also

Derivative, Numerical Differentiation

Explore with Wolfram|Alpha

References

Al-Mohy, A. H. and Higham, N. J. "The Complex Step Approximation to the Fréchet Derivative of a Matrix Function." Numer. Algorithms 53, 133-148, 2010. https://doi.org/10.1007/s11075-009-9323-y.Cossette, C. C.; Walsh, A.; and Forbes, J. R. "The Complex-Step Derivative Approximation on Matrix Lie Groups." IEEE Robot. Autom. Lett. 5, 906-913, 2020. https://doi.org/10.1109/LRA.2020.2965882.Martins, J. R. R. A.; Sturdza, P.; and Alonso, J. J. "The Complex-Step Derivative Approximation." ACM Trans. Math. Softw. 29, 245-262, 2003. https://doi.org/10.1145/838250.838251.Roelfs, M.; Dudal, D.; and Huybrechs, D. "Quaternionic Step Derivative: Machine Precision Differentiation of Holomorphic Functions Using Complex Quaternions." J. Comput. Appl. Math. 398, 113699, 2021. https://doi.org/10.1016/j.cam.2021.113699.Squire, W. and Trapp, G. "Using Complex Variables to Estimate Derivatives of Real Functions." SIAM Rev. 40, 110-112, 1998. https://doi.org/10.1137/S003614459631241X.

Cite this as:

Weisstein, Eric W. "Complex Step Differentiation." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/ComplexStepDifferentiation.html

Subject classifications