0
$\begingroup$

I created a simple code to calculate roots of a complex number using De Moivre's formula. I would like to draw these elements.

Program[] :=Block[{},
z=Input["set complex number"];
n=Input["give the degree of the square root of a complex number"];
kat=Arg[z];
zmd=Sqrt[Re[z]^2+Im[z]^2];
y=(zmd)^(1/n)*(Cos[(kat+2*x*Pi)/n]+I*Sin[(kat+2*x*Pi)/n]);
If[Im[z]!=0,For[x=0,x<=n-1,x++, Print[x," root is ", Simplify[y]]],Print["root is ",Re[z]^(1/n)] 
];
$\endgroup$
2

1 Answer 1

0
$\begingroup$

Thanks, meanwhile I managed to solve the problem.

Program[] :=Block[{},
z=Input["enter the complex number of the root you want to calculate"];
n=Input["enter the square root you want to calculate"];
kat=Arg[z];
zmd=Sqrt[Re[z]^2+Im[z]^2];
d=(zmd)^(1/n)*(Cos[(kat+2*b*Pi)/n]+I*Sin[(kat+2*b*Pi)/n]);
If[Im[z]!=0,For[b=0,b<=n-1,b++, Print[b," the square root of a complex number is ", ComplexExpand[d]]],Print["square root of a natural number is ",Re[z]^(1/n)] 
];
Print[ComplexListPlot[u /. Solve[u^n == z, u] ]]
]
Program[]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.