Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.
DynamicModule[{n = 7}, solns = Solve[x^n - 1 == 0, x]; 
 myxvals = x /. solns; 
 myarrows = 
  Table[Arrow[{{0, 0}, {Re[myxvals[[k]]], Im[myxvals[[k]]]}}], {k, 1, 
    n}]; mytext = 
  Table[Text[
    ComplexExpand[x /. solns[[k]]], {Re[myxvals[[k]]] + 0.1`, 
     Im[myxvals[[k]]] - 0.1`}, {-1, 0}], {k, 1, n}]; 
 Graphics[{{Red, myarrows}, {PointSize[Large], Blue, Point[{0, 0}]}}, 
  PlotLabel -> 
   Style[Row[{Style["x", Italic]^n, -1, " = ", 0}], 24, Bold], 
  Epilog -> mytext, PlotRange -> {{-1.1`, 1.4`}, {-1.5`, 1.1`}}, 
  ImageSize -> {300, 300}]]

I am trying to tranform this by using Manipulate. What I was to do is to give n a range between 1 and 8 and be able to manipulate the graph afterwards with these values. How do I do that????????

share|improve this question

closed as off-topic by Sjoerd C. de Vries, belisarius, Pickett, ubpdqn, rm -rf Mar 13 at 21:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Sjoerd C. de Vries, belisarius, Pickett, ubpdqn, rm -rf
If this question can be reworded to fit the rules in the help center, please edit the question.

2  
What have you tried that did not work? This is pretty easily found in the documentation of Manipulate. –  István Zachar Mar 10 at 18:59
add comment

1 Answer 1

Manipulate[solns = Solve[x^n - 1 == 0, x];
 myxvals = x /. solns;
 myarrows = 
  Table[Arrow[{{0, 0}, {Re[myxvals[[k]]], Im[myxvals[[k]]]}}], {k, 1, 
    n}]; mytext = 
  Table[Text[
    ComplexExpand[x /. solns[[k]]], {Re[myxvals[[k]]] + 0.1`, 
     Im[myxvals[[k]]] - 0.1`}, {-1, 0}], {k, 1, n}];
 Graphics[{{Red, myarrows}, {PointSize[Large], Blue, Point[{0, 0}]}}, 
  PlotLabel -> 
   Style[Row[{Style["x", Italic]^n, -1, " = ", 0}], 24, Bold], 
  Epilog -> mytext, PlotRange -> {{-1.1`, 1.4`}, {-1.5`, 1.1`}}, 
  ImageSize -> {300, 300}], {{n, 7}, 1, 8, 1}]
share|improve this answer
add comment

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