sqrt function
Return the square root of complex
. This has the same branch cut as log.
Implementation
Complex<num, num> sqrt(Complex complex) {
var r = math.sqrt((abs(complex) + complex.real) / 2);
var i = (complex.imaginary / complex.imaginary.abs()) *
math.sqrt((abs(complex) - complex.real) / 2);
return Complex<num, num>(r, i);
}