0

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)] 
];
user64494
  • 26,149
  • 4
  • 27
  • 56
Luka
  • 1

1 Answers1

0

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[]
Luka
  • 1