SIAM News Blog

The Unwinding Number

By Nicholas Higham

While Fortran 66 had a complex data type, this was not true of most other early programming languages, such as Algol 60. As a result, programmers had to write their own procedures to implement complex arithmetic and transcendental functions in terms of separately stored real and imaginary parts. They quickly realized that this is not a trivial task; in the early 1960s, it took five published attempts over three years to obtain a correct implementation of the complex logarithm in Algol 60.

Nowadays we take for granted the seamless availability of complex arithmetic and complex elementary functions in languages such as MATLAB, Julia, and Python. The questions that arise when computing in complex arithmetic often revolve around multi-valued functions, such as the logarithm.

Certain relations that are obviously true for positive real numbers, such as \(\log \textrm{e}^x = x\) and \(\log xy = \log x + \log y\), do not generally hold for complex arguments. If you consult a textbook on complex analysis, you will likely find statements such as "\(\log z_1 z_2 = \log z_1 + \log z_2\) holds for all \(z_1\) and \(z_2\) with an appropriate choice of the branch of the logarithm in each term.” This is not terribly helpful for an applied mathematician who wants to use a specific branch.

In practice, it is usually the principal logarithm—the one whose imaginary part lies on the interval \((-\pi,\pi]\) —that is of interest. From this point on, let \(\log\) denote the principal logarithm.

The equation \(\log \textrm{e}^z = z\) can clearly only hold if \(\textrm{Im} z \in (-\pi,\pi]\). If \(\textrm{Im} z\) is outside this range, then a discrepancy of some integer multiple of \(2\pi \textrm{i}\) exists in the equation. Would it be useful to give this discrepancy a name?

Rob Corless, David Hare, and David Jeffrey asked this question in 1996 [5, 7]. Deciding that the answer was “yes,” they defined the unwinding number of \(z\) by 

\[\mathcal{U}(z) = \frac{z-\log \textrm{e}^z}{2\pi \textrm{i}}\]

(the unwinding number is unrelated to the winding number of a contour in the complex plane). It is not hard to show that

\[ \mathcal{U}(z) = \bigg\lceil\frac{\textrm{Im} z - \pi}{2\pi}\bigg\rceil, \tag1 \]

where \(\left \lceil \cdot \right \rceil \) is the ceiling function; thus, the unwinding number is an integer. Since

\[z = \log \textrm{e}^z + 2\pi \textrm{i} \mathcal{U}(z),\]

it is clear that \(z = \log \textrm{e}^z\) (that is, \(\mathcal{U}(z) = 0\)) if and only if  \(\textrm{Im} z \in (-\pi,\pi]\).

Cartoon created by mathematician John de Pillis.

Corless and his coauthors realized that \(\mathcal{U}\) is a useful tool to analyze a wide range of complex arithmetic functions. Our original question about a product’s \(\log\) has a neat answer in terms of \(\mathcal{U}\):

\[\log (z_1 z_2) = \log z_1 + \log z_2 - 2\pi \textrm{i} \mathcal{U}(\log z_1 +\log z_2).\]


\[(z_1z_2)^{1/2} = z_1^{1/2}z_2^{1/2}(-1)^{\mathcal{U}(\log z_1+\log z_2)},\]

where the square root is the principal square root (the one that lies in the right half-plane).

The unwinding number can aid thinking and simplify proofs. For example, is it true that \((1-z)^{1/2}(1+z)^{1/2} = (1-z^2)^{1/2}\)? It turns out that it is, but the subtly different identity \((z-1)^{1/2} (z+1)^{1/2} = (z^2- 1)^{1/2}\) is true only for \(\arg z \in(-\pi/2,\pi/2)\). The unwinding number enables neat proofs of these results [3].

The unwinding number is also valuable when answering questions such as “when does \(\textrm{acos}(\cos z) = z\) hold?", which is useful to know when testing the correctness of an arc cosine function implementation [2].

The unwinding number generalizes to matrices in an obvious way: by replacing \(z\) with \(A\in\mathbb{C}^{n\times n}\) in \((1)\) [1]. In the case of a matrix, it proves extremely useful for understanding the behavior of multivalued matrix functions [2].

The unwinding number is gradually gaining recognition. It is a built-in function in Maple (called unwindK), and is starting to appear in books [4, 6]. It is a valuable addition to our toolkit for handling multivalued complex functions.

[1] Aprahamian, M., & Higham, N.J. (2014). The Matrix Unwinding Function, with an Application to Computing the Matrix Exponential. SIAM J. Matrix Anal. Appl., 35, 88-109.
[2] Aprahamian, M., & Higham, N.J. (2016). Matrix Inverse Trigonometric and Inverse Hyperbolic Functions: Theory and Algorithms. SIAM J. Matrix Anal. Appl., 37, 1453-1477.
[3] Bradford, R., Corless, R.M., Davenport, J.H., Jeffrey, D.J., & Watt, S.M. (2002). Reasoning about the Elementary Functions of Complex Analysis. Ann. Math. Artific. Intell., 36, 303-318.
[4] Corless, R.M., & Fillion, N. (2013). A Graduate Introduction to Numerical Methods: from the Viewpoint of Backward Error Analysis. New York, NY: Springer-Verlag.
[5] Corless, R.M., & Jeffrey, D.J. (1996). The Unwinding Number. SIGSAM Bull., 30, 28-35.
[6] Higham, N.J. (2008). Functions of Matrices: Theory and Computation. Philadelphia, PA: Society for Industrial and Applied Mathematics.
[7] Jeffrey, D.J., Hare, D.E.G., & Corless, R.M. (1996). Unwinding the Branches of the Lambert W Function. Math. Scientist, 21, 1-7.

Nicholas Higham is Royal Society Research Professor and Richardson Professor of Applied Mathematics at the University of Manchester. He is the current president of SIAM. 
blog comments powered by Disqus