pow method

Complex pow(
  1. double p
)

Implementation

Complex pow(double p) {
  double r = math.sqrt(real * real + imaginary * imaginary);
  double theta = math.atan2(imaginary, real);
  double magnitude = math.pow(r, p).toDouble();
  double arg = theta * p;

  double realPart = magnitude * math.cos(arg);
  double imagPart = magnitude * math.sin(arg);

  return Complex(realPart, imagPart);
}