Computing logarithms of complex numbers
The previous post showed how to compute logarithms using tables. It gives an example of calculating a logarithm to 15 figures precision using tables that only allow 4 figures of precision for inputs.
Not only can you bootstrap tables to calculate logarithms of real numbers not given in the tables, you can also bootstrap a table of logarithms and a table of arctangents to calculate logarithms of complex numbers.
One of the examples in Abramowitz and Stegun (Example 7, page 90) is to compute log(2 + 3i). How could you do that with tables? Or with a programming language that doesn't support complex numbers?
What does this even mean?Now we have to be a little careful about what we mean by the logarithm of a complex number.
In the context of real numbers, the logarithm of a real number x is the real number y such that ey = x. This equation has a unique solution ifx is positive and no solution otherwise.
In the context of complex numbers, a logarithm of the complex number z is any complex number w such that ew = z. This equation has no solution if z = 0, and it has infinitely many solutions otherwise: for any solution w, w + 2ni is also a solution for all integers n.
SolutionIf you write the complex number z in polar form
z = r ei
then
log(z) = log(r) + i.
The proof is immediate:
elog(r) + i = elog(r) ei = r ei.
So computing the logarithm of a complex number boils down to computing its magnituder and its argument .
The equation defining a logarithm has a unique solution if we make a branch cut along the negative real axis and restrict to be in the range - < . This is called the principal branch of log, sometimes written Log. As far as I know, every programming language that supports complex logarithms uses the principal branch implicitly. For example, in Python (NumPy), log(x) computes the principal branch of the log function.
ExampleGoing back to the example mentioned above,
log(2 + 3i) = log( (2^2 + 3^2) ) + arctan(3/2) = log(13) + arctan(3/2) i.
This could easily be computed by looking up the logarithm of 13 and the arc tangent of 3/2.
The exercise in A&S actually asks the reader to calculate log(2 3i). The reason for the variety of signs is to require the reader to pick the value of that lies in the range - < . For example,
log(-2 + 3i) = = log(13) + ( - arctan(3/2)) i.
The post Computing logarithms of complex numbers first appeared on John D. Cook.