The CLN function accepts a complex number and returns the natural logarithm—to base e —of that number. The complex natural logarithm of a number is calculated by means of DeMoivre's relationship and the relationships among x, y, r, and phi as follows:
CLN(x + iy) = LN(r) + i*phi
In this algorithm, phi is chosen to fall in the principal range noted, and both r and phi are as previously defined. The natural logarithm is computed as a real number. The value of phi is computed by the real intrinsic ARCTAN2, which is designed for use in this application. Then the algorithm becomes the following:
CLN(x+iy) = LN(SQRT(x**2 +y**2))+ i ARCTAN2(y,x)
Because the complex logarithm is not a single-value function, the value returned by CLOG is in the range -pi through +pi.