how matlab calculate the sqrt of complex number?
14 次查看(过去 30 天)
显示 更早的评论
Hi, I've written an algorithm which calculate the sqrt of complex number.
%%%%%%%
a_re=-3;
a_im=-6;
rho= sqrt(a_re*a_re+a_im*a_im);
teta=atan(a_im/a_re);
k=0;
risre=sqrt(rho)* cos(teta/2+2*pi*k/2)
risim=sqrt(rho)* sin(teta/2+2*pi*k/2)
%%%%%%%
but the result is'n the same of (-3-6i)^(1/2). Why? I would like to have the same results.
0 个评论
回答(1 个)
Babak
2013-3-20
usually powers of between 0 and 1 of complex numbers have multiple answers! As an example, (-3-6i)^(1/2)
[THETA,RHO] = cart2pol(-3,-6)
results in
THETA =
-2.0344
RHO =
6.7082
Thus
-3-6i = RHO*exp(i*THETA)
and therefore its half root is
(-3-6i)^.5 = RHO^.5*exp(i*THETA/2) = 1.3617 - 2.2032i
and
(-3-6i)^.5 = RHO^.5*exp(i*(THETA+2*pi)/2) = -1.3617 + 2.2032i
This is while MATLAB's sqrt function only gives the first answer, i.e. RHO^.5*exp(i*THETA/2)
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!