Problem with the sqrt function

3 次查看(过去 30 天)
Chirag Anand
Chirag Anand 2017-6-8
评论: Stephen23 2017-6-8
when I use the sqrt function to find the sqrt of a determinant of a complex matrix, sometimes matlab changes the sign of the real and imaginary part of the square root. for example if the it is -x+iy the sqrt function gives the answer as x-iy How do I get around this?
  2 个评论
Adam
Adam 2017-6-8
编辑:Adam 2017-6-8
Just like in the real case, if a is a square root then so is -a. In the real case the positive square root is always returned, for complex numbers the documentation states that 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.
Stephen23
Stephen23 2017-6-8
"Problem with the sqrt function"
What is the problem? sqrt is giving a correct output.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by