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 + 3*i*). 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 *e*^{y} = *x*. This equation has a unique solution if *x* 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 *e*^{w} = *z*. This equation has no solution if *z* = 0, and it has infinitely many solutions otherwise: for any solution *w*, *w* + 2*n*π*i* is also a solution for all integers *n*.

## Solution

If you write the complex number *z* in polar form

*z* = *r* *e*^{iθ}

then

log(*z*) = log(*r*) + *i*θ.

The proof is immediate:

*e*^{log(r) + iθ} = *e*^{log(r)} *e*^{iθ} = *r* *e*^{iθ}.

So computing the logarithm of a complex number boils down to computing its magnitude *r* 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.

## Example

Going back to the example mentioned above,

log(2 + 3*i*) = log( √(2² + 3²) ) + 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 ± 3*i*). 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 + 3*i*) = = ½ log(13) + (π − arctan(3/2)) *i*.