Abstract
In computational contexts, analytic functions are often best represented by grid-based function values in the complex plane. For integrating periodic functions, the spectrally accurate trapezoidal rule (TR) then becomes a natural choice, due to both accuracy and simplicity. The two key present observations are (i) the accuracy of TR in the periodic case can be greatly increased (doubling or tripling the number of correct digits) by using function values also along grid lines adjacent to the line of integration and (ii) a recently developed end correction strategy for finite interval integrations applies just as well when using these enhanced TR schemes.
Similar content being viewed by others
Notes
If an analytic functions is somewhat costly to evaluate, it may be desirable to pay a one-time cost of evaluating over a grid and then re-use this data for multiple purposes, such as for graphical displays (e.g., [7, 12]) and, as focused on here, for highly accurate contour integrations (assuming some vicinity of the integration paths to be free of singularities). In some cases, the fastest evaluation method for the function is naturally grid based (e.g., the Painlevé functions [8]).
First observed by Poisson in the 1820s [9]
Although many papers discuss and give error estimates for the periodic TR, there seem to be few—if any—previous references on utilizing this type of supplementary information for improving the accuracy. A somewhat related procedure was used in [3] for approximating derivatives/Taylor coefficients (c.f., its equations (5)–(9)).
We recall the assumption that grid-based data is more economically available than “fresh” function evaluations. If not, it would be more cost effective to double and triple the number of nodes in the 1-line TR than to apply the 3-line and 5-line TR versions, respectively.
Appendix A in [5] sketches three derivations with references to still further ones.
As was done in [4]
The last parameter in the NSolve statement specifies the precision (number of decimal digits) to be used in this calculation of the coefficients.
Advanpix, Multiprecision Computing Toolbox for MATLAB, http://www.advanpix.com/, Advanpix LLC., Yokohama, Japan.
Figure 6 in [4] shows similarly the nodes used when integrating along the rectangle in the Cartesian node case.
One higher than the number of nodes in the correction stencil.
In Section 4.3 of [4], end corrected 1-line TR is compared against Gaussian and Clenshaw-Curtis quadratures for the test problem \({\int \limits }_{-1}^{1}f(z)dz\).
When expressed as derivatives of odd orders at the end point(s)
After the leading term, both expansions are geometric progressions that are readily summed in closed form, giving \(\pi \cot (\pi (x+iy))\) in their respective regions of convergence.
References
Birkhoff, G., Young, D.: Numerical quadrature of analytic and harmonic functions. J. Math. Physics 29, 217–221 (1950)
Burne, C. R.: Derivative corrections to the trapezoidal rule. arXiv:1808.04743v1 [math.NA] (2018)
Fornberg, B.: Numerical differentiation of analytic functions. ACM Trans. Math. Software 7(4), 512–526 (1981)
Fornberg, B.: Contour integrals of analytic functions given on a grid in the complex plane. IMA Journal of Num. Anal (to appear) (2020)
Fornberg, B.: Euler-Maclaurin expansions without analytic derivatives. submitted (2020)
Fornberg, B.: Improving the accuracy of the trapezoidal rule. SIAM Review (to appear) (2020)
Fornberg, B., Piret, C.: Complex Variables and Analytic Functions: an Illustrated Introduction. SIAM (2020)
Fornberg, B., Weideman, J.A.C.: A numerical method for the Painlevé equations. J. Comput. Phys. 230, 5957–5973 (2011)
Poisson, S.D.: Sur le calcul numérique des intégrales définies. Mémoires de l’Académie Royale des Sciences de l’Institute de France 4, 571–602 (1827)
Trefethen, L.N.: Is Gauss quadrature better than Clenshaw-Curtis? SIAM Rev. 50(1), 67–87 (2008)
Trefethen, L.N., Weideman, J.A.C.: The exponentially convergent trapezoidal rule. SIAM Rev. 56, 384–458 (2014)
Wegert, E.: Visual Complex Functions. Birkhäuser (2012)
Weideman, J.A.C.: Numerical integration of periodic functions: a few examples. Amer. Math. Monthly 109, 21–36 (2002)
Acknowledgments
Discussions with André Weideman are gratefully acknowledged.
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.
Appendix. Derivation of multi-line periodic TR formulas by means of contour integration
Appendix. Derivation of multi-line periodic TR formulas by means of contour integration
For notational simplicity, we set h = 1 and let the problem be periodic over 0 ≤ x ≤ N. With the path Γ illustrated in Fig. 7a,
We next note:
-
1.
The value of \({\int \limits }_{P}f(z)dz\) along the period line P = [0, N] is unaffected if this path is translated sideways or up/down (assuming f(z) is singularity-free in the region of interest), and
-
2.
With z = x + iy, it holds thatFootnote 16
$$ \pi \cot\pi z = \left\{ \begin{array}{ll} -i\pi \left( 1+2e^{+2i\pi x}e^{-2\pi y} + 2e^{+4i\pi x}e^{-4\pi y}+2e^{+6i\pi x}e^{-6\pi y} + \ldots\right) & \textrm{if }y > 0\\ +i\pi \left( 1+2e^{-2i\pi x}e^{+2\pi y} + 2e^{-4i\pi x}e^{+4\pi y}+2e^{-6i\pi x}e^{+6\pi y} + \ldots\right) & \textrm{if }y < 0 \end{array}\right. . $$(19)
Equation (18) tells that TR would give the exact value for \({\int \limits } f_{P}(z)dz\) if it was not for \(\pi \cot \pi z\) approaching ∓ iπ only exponentially fast (19) rather than instantaneously when y deviates from zero, c.f., Fig. 8.
The different multi-line TR formulas follow now in the same manner as described below for the 3-line Cartesian case. Consider for this case the contour integration illustrated in Fig. 7b, with the three rows of poles given the weights α, β, and γ, respectively. Defining
we want the approximation
to be as accurate as possible. From the argument above, this happens if g(z; α,β, γ) approaches as fast as possible − iπ for y increasing past y = 1 and + iπ for y decreasing below y = − 1. Given (19), this occurs when
implying
with the solution \(\left \{ \alpha ,\upbeta ,\gamma \right \} =\frac {1}{(2\sinh \pi )^{2}}\left \{ -1,2\cosh 2\pi ,-1\right \} \), matching (4). The system (21) is equivalent to the one previously solved when obtaining (4) from (1), (2), and (3).
Figure 8 illustrates \(\text {Im}(\pi \cot \pi z)\), i.e., Im(g(z; α,β, γ)) in the original 1-line TR case of {α, β, γ} = {0, 1, 0}. With the 3-line TR coefficients {α,β, γ}≈{− 0.001874, 1.00375,− 0.001874}, the residues at the poles along the real axis are very slightly increased, and there will be very small residue poles also along y = ± 1. Figure 9a shows exactly the same data as Fig. 8, but limited in the y-direction to [0.7, 1.6]. The counterpart illustration for the 3-line TR is seen in Fig. 9b. The row of poles along y = 1 have negative residues, making them visually appear as if they were shifted in the x-direction. For increasing y, these poles perfectly cancel out the dominant Fourier mode in the x-direction (as seen along the left edge in the two plots).
Rights and permissions
About this article
Cite this article
Fornberg, B. Generalizing the trapezoidal rule in the complex plane. Numer Algor 87, 187–202 (2021). https://doi.org/10.1007/s11075-020-00963-0
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s11075-020-00963-0