complex_sqrt

Function complex_sqrt 

Source
pub(crate) fn complex_sqrt(z: Complex) -> Complex
Expand description

The principal square root of z, equal to z.sqrt() up to rounding.

The algebraic form avoids the atan2, sin and cos of num-complex’s polar form. Inputs whose larger part lies outside [1e-150, 1e150] are scaled first, so the squares neither overflow nor underflow. The sign of a zero imaginary part picks the side of the branch cut on the negative real axis: complex_sqrt(-1 - 0i) = -i.