how matlab calculate the sqrt of complex number?

18 vues (au cours des 30 derniers jours)
max
max le 20 Mar 2013
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.

Réponses (1)

Babak
Babak le 20 Mar 2013
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)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by