A complex number
The complex natural logarithm of x
| x | log(x) |
|---|---|
| (-0, +0) | (-∞, π) |
| (+0, +0) | (-∞, +0) |
| (any, +∞) | (+∞, π/2) |
| (any, NaN) | (NaN, NaN) |
| (-∞, any) | (+∞, π) |
| (+∞, any) | (+∞, +0) |
| (-∞, +∞) | (+∞, 3π/4) |
| (+∞, +∞) | (+∞, π/4) |
| (±∞, NaN) | (+∞, NaN) |
| (NaN, any) | (NaN, NaN) |
| (NaN, +∞) | (+∞, NaN) |
| (NaN, NaN) | (NaN, NaN) |
import mir.math.common: sqrt; import mir.math.constant: PI; import mir.math.common: approxEqual; auto a = complex(2.0, 1.0); assert(log(conj(a)) == conj(log(a))); assert(log(complex(-1.0L, 0.0L)) == complex(0.0L, PI)); assert(log(complex(-1.0L, -0.0L)) == complex(0.0L, -PI));
Calculate the natural logarithm of x. The branch cut is along the negative axis.