sqrt
Square root
Syntax
B = sqrt(X)
Description
B = sqrt(
returns the square root of each element of the arrayX
)X
. For the elements ofX
that are negative or complex,sqrt(X)
produces complex results.
Thesqrt
function’s domain includes negative and complex numbers, which can lead to unexpected results if used unintentionally. For negative and complex numbersz = u + i*w
,复杂的平方根sqrt(z)
returns
sqrt(r)*(cos(phi/2) + 1i*sin(phi/2))
wherer = abs(z)
is the radius andphi = 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, userealsqrt
instead.
Examples
Input Arguments
Tips
Seesqrtm
for the matrix square root.
Extended Capabilities
Introduced before R2006a
Was this topic helpful?