log2 method

Complex log2()

Calculates the base-2 logarithm of the complex number.

Implements the formula:

log2(z) = log(z) / log(2)

Where log is the natural logarithm.

Example:

var z = Complex(8, 0);
var z_log2 = z.log2();
print(z_log2); // Output: 3 + 0i

Implementation

Complex log2() {
  if (isNaN) return Complex.nan();
  if (isZero) return Complex(double.negativeInfinity, 0);
  return log() / math.ln2;
}