0
$\begingroup$

I have a list with complex numbers and I want to animate them. How can i do this? I would like to have appearing lines between points. I hope you know what I mean. Here is my code:

 roots[re_, im_, n_] := 
     Module[{a = re, b = im, zkList, phi, zk, k, IM, RE, zkList2, p, 
       number},
      number = a + I*b;
      zkList = 
       Table[{Power[Abs[re + im*I], (
           n)^-1]*(Cos[(Arg[re + im*I] + 2*k*Pi)/n]) + 
          I*Sin[(Arg[re + im*I] + 2*k*Pi)/n]}, {k, 0, n - 1}];
        zkList]

Example:

roots[1, 0, 4]
{1, I, -1, -I}
$\endgroup$
  • $\begingroup$ It's not clear what you're asking. Lines between what points? $\endgroup$ – MelaGo Oct 24 at 23:48
2
$\begingroup$

I am not sure I understand what is the aim. I post this as motivation. Apologies for errors and misunderstanding. Manipulate andDynamicModule are useful for dynamic/interactive exploration. Locator can allow you to explore different z. Slider2D can also be useful.

Here is an example:

Manipulate[
 Module[{r = Norm[pt]^(1/n), pts}, 
  pts = Table[
    r {Cos[ArcTan @@ pt/n + 2 Pi j/n], 
      Sin[ArcTan @@ pt/n + 2 Pi j/n]}, {j, 0, n - 1}]; 
  Graphics[{Point[pt], Red, PointSize[0.03], Point[pts], Blue, 
    Circle[{0, 0}, Norm[pt]], Orange, FaceForm[None], 
    EdgeForm[Orange], Polygon[pts], Circle[{0, 0}, r], Black, 
    Line[{{0, 0}, #}] & /@ pts, Circle[{0, 0}, 1]}, Frame -> True, 
   PlotRange -> {{-3, 3}, {-3, 3}}]], {{pt, {1, 0}}, Locator}, {n, 
  Range[2, 7]}]

enter image description here

$\endgroup$
  • $\begingroup$ ‘Here’? Is that meant to be a hyperlink? I am happy to delete my answer. $\endgroup$ – ubpdqn Oct 25 at 9:15
  • $\begingroup$ Hello, thank for your post. Here is what I meant. 'Animate[ListPlot[zkList[[1 ;; i]], PlotMarkers -> {Automatic, Small}, Joined -> True, PlotRange -> {{-2, 2}, {-2, 2}}], {i, 1, n, 1}]' Unfortunately, it does not show line between first and last point. Do you know how to fix this? $\endgroup$ – Janukalado Oct 25 at 9:17
  • 2
    $\begingroup$ @Janukalado you could just modify your Table from 0 to n to repeat the first element and allow closure. Otherwise use Graphics and Polygon. $\endgroup$ – ubpdqn Oct 25 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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