Abstract
Among general functions of two variables f(x, y), analytic functions f(z) with z = x + iy form a very important special case. One consequence of analyticity turns out to be that 2-D finite difference (FD) formulas can be made remarkably accurate already for small stencil sizes. This article discusses some key properties of such complex plane FD formulas. Application areas include numerical differentiation, interpolation, contour integration, and analytic continuation.







Similar content being viewed by others
Notes
Chapter 1 of [12] gives several algorithms for computing FD weights in 1-D on either equi-spaced or irregularly spaced nodes, with its later chapters focusing on non-Cartesian node layouts in multiple dimensions.
cf., (3) below.
The reverse statement that the CR equations imply analyticity requires only slight “fine print,” to rule out cases such as \(f(z)=e^{-1/z^{4}},\) for which the CR equations hold also at the point of discontinuity z = 0.
Chapter 1 in [12] provides a summary of FD methods, including method 1. Method 2 produces the identical linear system to solve (differing only in how the equations are scaled).
Such as the Painlevé transcendents, cf., [14].
See for ex. [12], Section 1.2.2.
See for ex. [13], Theorem 2.12.
Given the stencil size for u, this weight set is not unique, but it becomes unique if we impose the expected symmetries in the two directions.
Method 1 can similarly be adapted to provide highly accurate FD formulas for derivatives of harmonic functions.
Hermite-FD formulas approximate the pth derivative, p ≥ 2, using both function and first derivative values: \(f^{(p)}(0)\approx {\sum }_{k=-n}^{n}b_{k}f(k)+{\sum }_{k=-n}^{n}c_{k}f^{\prime }(k)\). Their infinite order PS limit is similar to that of regular FD-PS methods, as analyzed in [2].
Multiprecision Computing Toolbox for MATLAB, http://www.advanpix.com/, Advanpix LLC, Yokohama, Japan.
References
Abate, J., Dubner, H.: A new method for generating power series expansion of functions. SIAM J. Numer. Anal. 5, 102–112 (1968)
Abrahamsen, D., Fornberg, B.: On the infinite order limit of Hermite-based finite difference schemes. SIAM J. Numer. Anal. 59(4), 1857–1874 (2021)
Ahlfors, L. V.: Complex Analysis. McGraw-Hill, New York (1966)
Birkhoff, G., Young, D.: Numerical quadrature of analytic and harmonic functions. J. Math. Phys. 29, 217–221 (1950)
Bornemann, F.: Accuracy and stability of computing high-order derivatives of analytic functions by Cauchy integrals. Found. Comput. Math. 11, 1–63 (2011). https://doi.org/10.1007/s10208--010--9075--z
Fornberg, B.: Numerical differentiation of analytic functions. ACM Trans. Math. Softw. 7(4), 512–526 (1981)
Fornberg, B.: A Practical Guide to Pseudospectral Methods. Cambridge University Press (1996)
Fornberg, B.: Euler-Maclaurin expansions without analytic derivatives. Proc. Royal Soc. Lond. Ser. A 476(20200441). https://doi.org/10.1098/rspa.2020.0441 (2020)
Fornberg, B.: Contour integrals of analytic functions given on a grid in the complex plane. IMA J. Numer. Anal. 41, 814–825 (2021). https://doi.org/10.1093/imanum/draa024
Fornberg, B.: Generalizing the trapezoidal rule in the complex plane. Numer. Algorithm. 87, 187–202 (2021)
Fornberg, B.: Improving the accuracy of the trapezoidal rule. SIAM Rev. 63(1), 167–180 (2021)
Fornberg, B., Flyer, N.: A Primer on Radial Basis Functions with Applications to the Geosciences, CBMS-NSF, vol. 87. SIAM, Philadelphia (2015)
Fornberg, B., Piret, C.: Complex Variables and Analytic Functions: An Illustrated Introduction. SIAM, Philadelphia (2020)
Fornberg, B., Weideman, J. A. C.: A numerical methodology for the Painlevé equations. J. Comput. Phys. 230, 5957–5973 (2011)
Hinojosa, J. H., Mickus, KL: Hilbert transform of gravity gradient profiles: Special cases of the general gravity-gradient tensor in the Fourier transform domain. Geophysics 67(3), 766–769 (2002)
Huybrechs, D.: Stable high-order quadrature rules with equidistant points. Comput. Appl. Math. 231, 933–947 (2009)
LeVeque, R. J.: Finite Difference Methods for Ordinary and Partial Differential Equations. SIAM, Philadelphia (2007)
Lyness, J. N., Moler, C. B.: Numerical differentiation of analytic functions. SIAM J. Numer. Anal. 4, 202–210 (1967)
Lyness, J. N., Sande, G.: Algorithm 413-ENTCAF and ENTCRE: Evaluation of normalized Taylor coefficients of an analytic function. Comm. ACM 14(10), 669–675 (1971)
Richardson, L.F.: On the approximate arithmetical solution by finite differences of physical problems involving differential equations, with an application to the stresses in a masonry dam. Proc. R. Soc. A. 83, 307–357. https://doi.org/10.1098/rspa.1910.0020 (1910)
Trefethen, L. N.: Spectral Methods in MATLAB. SIAM, Philadelphia (2000)
Trefethen, L. N.: Approximation Theory and Approximation Practice, SIAM, Philadelphia. 2013 extended edition (2019)
Trefethen, L. N.: Quantifying the ill-conditioning of analytic continuation. BIT Numer. Math. 60, 901–915 (2020)
Author information
Authors and Affiliations
Corresponding author
Additional information
Publisher’s note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Appendices
Appendix 1: Code examples for the two weights algorithms
Let the task be to determine the weight set for the second derivative (i.e., L = d2/dz2) at the center of a 5 × 5 stencil. The next two sections illustrate how this can be done with the two methods described in Section 2. Comments indicate how to generalize to other node layouts and linear operators.
1.1 Method 1: MATLAB code

For node spacing h, we replace x = -2,2; by x = (-2,2)⋆h;. This code produces the same matrix as shown below for the Mathematica code, but as floating point numbers. Since the linear system is of Vandermonde type, it is prone to numerical ill-conditioning. In the present test case, using standard double precision, about 4 digits get lost, leading to coefficient errors up to about 10− 12. Since the loss increases rapidly with stencil size, either exact rational or extended precision arithmetic is recommended (available in all common symbolic algebra packages). When using MATLAB, both are available through its symbolic toolbox; the latter also with the Advanpix toolboxFootnote 14.
1.2 Method 2: Mathematica code
The following three Mathematica statements

compute the FD weights in closed form (with h as before denoting the node spacing). The further statement

displays this set of weights in a standard matrix format:

Appendix 2: Stencils of size 5 × 5 for the first four derivatives
For this stencil size, one can approximate up through f(24)(0) which then becomes first-order accurate.
Appendix 3
Following up on Section 8, we consider again
and note that
We next refer to Fig. 8, with a schematic illustration in the n = 4 case (with a total of N = (2n +-1)2 = 81 nodes), and μ = 2, ν = 1, i.e., zk = 2 + i (marked by a triangle, in contrast to z = 0 marked by a square). The value for \(\phi ^{\prime }(0)\), according to (24), is obtained by a product over all nodes inside the large solid square (omitting its center node). If the corresponding product for \(\phi ^{\prime }(z_{k})\) had used the nodes inside the dashed square (again omitting the center node), it would have evaluated to the same result. However, it does not, but a calculation for \(\log |\phi ^{\prime }(0)|\) becomes a calculation for \(\log |\phi ^{\prime }(z_{k})|\) if we to it add the sums
and subtract
Each of these four sums is readily estimated to leading order. Along the center line of each of the four narrow rectangles (marked 1, 2, 3, 4 in the figure), we can approximate the sum by suitable use of the integral relation
Illustration of the node sets used in the estimate of the sums S1,…, S4, as described in Appendix 10
together with multiplying each integral by the width (orthogonal to the center line) of the respective rectangle. After straightforward algebra, this gives
from with (20) then follows.
Rights and permissions
About this article
Cite this article
Fornberg, B. Finite difference formulas in the complex plane. Numer Algor 90, 1305–1326 (2022). https://doi.org/10.1007/s11075-021-01231-5
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s11075-021-01231-5
Keywords
- Finite differences
- Complex variables
- Analytic functions
- Euler-Maclaurin
- Contour integration
- Analytic continuation