sqrt method
Calculates the square root of this complex number.
Implementation
Complex sqrt() {
// In case this instance were a real, positive number, then we can simplify
// the calculation.
if ((imaginary == 0) && (real > 0)) {
return Complex.fromReal(math.sqrt(real));
}
final r = math.sqrt(abs());
final theta = phase() / 2;
return Complex(r * math.cos(theta), r * math.sin(theta));
}