The complex step method for
Some years ago I came across this idea while browsing a now-forgotten computing magazine, and thought I would pass it on. The reference is a 1967 paper by Lyness and Moler, available at epubs. For further details and implementation in various languages see Martins et al (2003). Moler’s blog sets the scene.
Start with an analytical function f, a point x0 on the real axis, and a parameter h > 0. By expanding f in a Taylor series off the x-axis and taking the imaginary part of both sides, we get f ′(x0) = Im(f(x0 + ih))/h + O(h2),
giving an approximation accurate to order h2 that is not subject to subtractive cancellation errors! An example is given in the R code below, for which f(x) = ex/(sin3(x) + cos3(x)), − π/4 ≤ x ≤ π/2,
and x0 = π/4. The results are compared with the finite-difference formula f ′(x0) ≈ (f(x0 + h) − f(x0 − h))/(2h).
As advertised, the complex step method reaches its double precision value when h = 10 − 8, while the finite difference method never does; it also fails dramatically as h ↓ 0.
Herbert and Florence Irving Director,
Herbert and Florence Irving Institute for Cancer Dynamics
Meet Our Associate Members
In this monthly newsletter, we will regularly feature
the many talented members of our Institute.
Ivan Corwin is a professor of mathematics, a member of the Program for Mathematical Genomics, of the Data Science Institute and of the Columbia Quantum Initiative at Columbia University. Ivan is also on the scientific advisory board for the NSF center (Institute for Computations and Experimental Research in Mathematics (ICERM). He studies aspects of probability and mathematical physics, including random interface growth, interacting particle systems, random matrix theory, and stochastic partial differential equations. Ivan leads the Probability and Society group, as part of the Columbia Science Initiative at Columbia University. Ivan is also interested in applications of probability in the biological sciences, for example, random matrix theory for the analysis of single-cell RNA-seq data.
Andrew Yates is a Professor of Pathology & Cell Biology and a member of the Data Science Institute and of the Program for Mathematical Genomics at Columbia University. Andy is a quantitative immunologist. His research integrates theoretical and computational tools with diverse experimental approaches to study the dynamics of lymphocytes, white blood cells that are key components of vertebrate immune systems. Andy is helping the IICD develop its research profile in immunology.