Complex Double-Precision Evaluation of the Wright Ω Function
Total Page:16
File Type:pdf, Size:1020Kb
Algorithm 917: Complex Double-Precision Evaluation of the Wright ω Function PIERS W. LAWRENCE, ROBERT M. CORLESS, and DAVID J. JEFFREY, The University of Western Ontario This article describes an efficient and robust algorithm and implementation for the evaluation of the Wright ω function in IEEE double precision arithmetic over the complex plane. Categories and Subject Descriptors: G.1.2 [Numerical Analysis]: Approximation—Special function approximations; G.1.5 [Numerical Analysis]: Roots of Nonlinear Equations—Error analysis, iterative methods General Terms: Algorithms, Design Additional Key Words and Phrases: Wright omega function, double-precision evaluation over C ACM Reference Format: Lawrence, P. W., Corless, R. M., and Jeffrey, D. J. 2012. Algorithm 917: Complex double-precision evaluation of the Wright ω function. ACM Trans. Math. Softw. 38, 3, Article 20 (April 2012), 17 pages. DOI = 10.1145/2168773.2168779 http://doi.acm.org/10.1145/2168773.2168779 1. INTRODUCTION The Wright ω function was studied implicitly, without being named, by Wright [1959], and named and defined by Corless and Jeffrey [2002]. Although the function has been incorporated into the MAPLE system and is indirectly available in other systems 20 (through the Lambert W function), there has been no development of an algorithm for floating-point evaluation. Here we describe an efficient algorithm, and implementa- tion in C for the IEEE double-precision evaluation of Wright ω over the complex plane. We discuss the conditioning of the evaluation, including a novel discussion of the sep- arate conditioning of the real and imaginary parts of the function and the efficiency of different iterative schemes. Wright ω can be thought of informally as the solution for complex z of the algebraic equation ω +lnω = z . (1) A more direct definition can be given in terms of the Lambert W function [Corless et al. 1996] by z ω (z) = WK(z) e . (2) This research was supported in part by the Natural Sciences and Engineering Research Council of Canada. Authors’ address: P. W. Lawrence, R. M. Corless, and D. J. Jeffrey, Ontario Research Centre for Computer Algebra and the Department of Applied Mathematics, The University of Western Ontario, London, Ontario, Canada N6A 5BT; email: {plawren, rcorless, djeffrey}@uwo.ca. Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies show this notice on the first page or initial screen of a display along with the full citation. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permit- ted. To copy otherwise, to republish, to post on servers, to redistribute to lists, or to use any component of this work in other works requires prior specific permission and/or a fee. Permissions may be requested from the Publications Dept., ACM, Inc., 2 Penn Plaza, Suite 701, New York, NY 10121-0701, USA, fax +1 (212) 869-0481, or [email protected]. c 2012 ACM 0098-3500/2012/04-ART20 $10.00 DOI 10.1145/2168773.2168779 http://doi.acm.org/10.1145/2168773.2168779 ACM Transactions on Mathematical Software, Vol. 38, No. 3, Article 20, Publication date: April 2012. 20:2 P. W. Lawrence et al. Here K(z)= (Im(z) − π)/(2π) is the unwinding number of z [Corless and Jeffrey 1996], which corrects for the fact that ln ez does not simplify to z when ln z stands for the principal branch of the logarithm of z [Corless et al. 2000]. Throughout this article, as indeed throughout computational mathematics nowadays, ln z, always denotes the principal branch only. Wright ω is of interest for many reasons. In applications, many problems soluble in terms of Lambert W have solutions in terms of the composition W(ez), and so are better expressed using ω. Further, ω is single valued, whereas Lambert W is multi- valued, and thus the complications of branches are avoided. From a numerical point of view, the floating-point computation of W(ez) suffers from unnecessary overflow. For large Re z, Lambert W behaves like ln z, meaning that the argument ez can overflow and prevent the accurate computation of ω(z) ∼ z. Additionally, both the unwinding number K(z) and the Lambert W function are discontinuous on their branch cuts, but (except in two cases) these discontinuities cancel out for Wright ω. Computation of a continuous function via discontinuous functions is a dubious numerical strategy. For these reasons, we describe a direct method here, meaning one that avoids any compu- tation of Lambert W. We recall some properties of Wright ω noted by Corless and Jeffrey [2002]. Wright ω is single valued but discontinuous along two straight lines in C described parametri- cally by zt = t+ iπ and its conjugate ref lection zt = t− iπ for t ≤−1. The discontinuities arise because if z lies on one of the lines, then ω is real and negative, implying that the term ln ω in (1) will be discontinuous, because of the branch cut of logarithm. Alterna- tively, the lines are images under the mapping z → ez of the branch cut of Lambert W, 1 with the end points zs = −1 ± iπ being images of the Lambert W branch point. The values of Wright ω on the lines of discontinuity are chosen so that the function is con- tinuous from below the lines, that is, ω(t ± iπ) = lim→0 ω(t ± iπ − i). The lines of discontinuity are shown in Figure 1 and their images are shown in Figure 2. Below, we shall need the derivative of Wright ω : dω ω = . (3) dz 1+ω In Table I, special values for ω are given. Values of z giving real values to ω are given first, followed by some complex values. The aim of this article is to describe a general-purpose IEEE double precision rou- tine to calculate the value of ω over the complex plane. We do not aim for a correctly rounded implementation [de Dinechin et al. 2007; Defour et al. 2004], which we ac- knowledge would be better, but rather only a reliable routine that gives uniformly small error for all possible valid complex floating-point input, and to return useful information in NaN form otherwise. To this end, we deploy and test several iterative schemes, which improve initial ap- proximations to ω obtained by series approximations and rational approximations over the various regions of the complex plane. This article looks at three different iterative schemes: Newton’s method, Halley’s method, and a fourth-order scheme similar to one used by Fritsch et al. [1973] for the Lambert W function. 1In the earlier publication [Corless and Jeffrey 2002], the line t + πi, t ≤−1 was called ‘the doubling line’. This terminology is a fossil from an earlier definition of the function, based on (1), and it is better replaced by ‘line of discontinuity’. Likewise, the endpoints have been called branch points, but simply calling them singular points is clearer, because Wright ω is single valued. ACM Transactions on Mathematical Software, Vol. 38, No. 3, Article 20, Publication date: April 2012. Algorithm 917: Double-Precision Evaluation of Wright ω 20:3 Fig. 1. The lines of discontinuity in the z plane and their images under z → ω(z). The vertical hatching shows that the value of ω on the lines is defined by taking the limit from below. The images of the lines in the ω plane cover the negative real axis, the branch cut of logarithm. The singular points at the ends of the lines of discontinuity, labeled b, c, f, g,allmaptoω = −1. Fig. 2. This plot shows the images of vertical and horizontal lines under the map z → ω(z). Two singular points are evident in the plot, at ω = −1andω =0.Thepointω = −1 corresponds to the points z = −1 ± π, labelled b, c, f, g in figure 1, and the square-root nature of the singularity is evident. The point ω =0 corresponds to z = −∞ + it,where−π<t ≤ π, labeled d, e in Figure 1. 2. CONDITIONING OF THE WRIGHT ω FUNCTION Before considering computational schemes, we establish the conditioning of the eval- uation problem in the complex plane, in order to highlight regions of difficulty requir- ing special treatment. Function evaluation, as a numerical problem, focuses on the forward error, but precisely how the forward error is measured remains a matter of ACM Transactions on Mathematical Software, Vol. 38, No. 3, Article 20, Publication date: April 2012. 20:4 P. W. Lawrence et al. Table I. Special Values of ω(z) z ω(z) −∞ 0 0 W0(1) = 0.56714 ... 1 1 1+e e −1+iπ −1 − − π − 1 i 1 − π − −2 − . ... 2+ln2+i W0 2e = 0 40638 − − π − −2 − 2+ln2 i W−1 2e = 2 1 π i 1+ 2 i iπ W0(−1) = −0.31813 + 1.3372 i 1+i 0.93721 + 0.50542 i choice. If ωe is an approximation to an exact complex value ω, then one can require |ω − ωe|/|ω| to be less than a small multiple of machine epsilon, or one can require the more stringent conditions that | Re(ω − ωe)|/| Re(ω)| and | Im(ω − ωe)|/| Im(ω)| be each less than a small multiple of machine epsilon. Here we use the first measure of accuracy, although we check the condition numbers for the real and imaginary parts also. We begin by noting that along the lines of discontinuity the Wright ω function is infinitely ill-conditioned.