Square root

Syntax and Description

sqrt(X) returns the square root of each element of the array X. For the elements of X that are negative or complex, sqrt(X) produces complex results. The sqrt function's domain includes negative and complex numbers, which can lead to unexpected results if used unintentionally. For negative and complex numbers z = u + i*w, the complex square root sqrt(z) returns
sqrt(r)*(cos(phi/2) + 1i*sin(phi/2))
where r = abs(z) is the radius and phi = angle(z) is the phase angle on the closed interval -pi <= phi <= pi.
If you want negative and complex numbers to return error messages rather than return complex results, use realsqrt instead.

Back to functions