Message Boards Message Boards

1 Reply
1 Total Likes
View groups...
Share this post:

Convert root to coordinate form

Posted 10 years ago

Hey, I want to convert the output of the Root function to coordinate in the form {{2,0}{-2,0}}, because I want to view them in the LocatorPane. Thats the code i wrote so far:

zero1 = x /. {ToRules[Roots[x^2 - 4 == 0, x]]};
xval[k_] := zero1[[k]]
yval = 0   
Join[{Do[List[xval[b], yval], {b, Exponent[x^2, x]}]}]

But if I evaluate it I just get {{0,0},{0,0}} as a result. The code should work for every polynomial function thats why I use the Do function

In the case of a polynomial with degree 2 the code

Join[{List[xval[1], yval]}, {List[xval[2], yval]}]

works. I just cant find the mistake I made or don't know how to solve in in mathematica.


On my system I get the result {Null}. That's because Do executes but does not give an output. This seems to work:

zero1 = x /. {ToRules[Roots[x^2 - 4 == 0, x]]};
xval[k_] := zero1[[k]]
yval = 0
Table[{xval[b], yval}, {b, Exponent[x^2, x]}]

However, I would rather achieve the goal this way:

{Re[x], Im[x]} /. NSolve[x^2 - 4 == 0, x]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract