log method

  1. @override
Cartesian log()
override

Compute the natural logarithm of this complex number.

Implements the formula:

log(a + bi) = ln(|a + bi|) + arg(a + bi)i

where ln on the right hand side is math.log, |a + bi| is the modulus, abs, and `arg(a + bi) = atan2(b, a).

Returns nan if either real or imaginary part of the input argument is NaN.

Infinite (or critical) values in real or imaginary parts of the input may result in infinite or NaN values returned in parts of the result.

Examples:

log(1 ± INFINITY i) = INFINITY ± (π/2)i
log(INFINITY + i) = INFINITY + 0i
log(-INFINITY + i) = INFINITY + πi
log(INFINITY ± INFINITY i) = INFINITY ± (π/4)i
log(-INFINITY ± INFINITY i) = INFINITY ± (3π/4)i
log(0 + 0i) = -INFINITY + 0i

Implementation

@override
Cartesian log() {
  if (isNaN) return Complex.nan;
  return Cartesian(math.log(abs()), fastmath.atan2(imaginary, real));
}