# The plot of roots of polynomials

I have polynomial equation like Tribonacci Polynomials for example: $T_3(x)=x^4+x$. After finding the roots of this polynomial, I want to show these roots in the complex plane.

I have tried lots of methods as follows but I haven't found one that worked:

f[x_] := x^4 + x;
ListPlot[x /. Solve[f[x] == 0, {x}]]


Plotting points in the complex plane can be easily arranged, like so:

rootPlot[poly_, x_, opts___] /; PolynomialQ[poly, x] :=
ListPlot[Map[Composition[Through, {Re, Im}], x /. NSolve[poly, x]],
opts, AspectRatio -> Automatic]


An example:

rootPlot[x^4 + x, x, Axes -> None, Frame -> True, PlotStyle -> AbsolutePointSize] Notes:

• Map[Composition[Through, {Re, Im}], roots] turns your list of complex numbers into a pair consisting of the real and imaginary parts, which can be easily processed by ListPlot[].

• Since you're just plotting them, you don't really need to go symbolic; NSolve[] is a bit quicker to use than Solve[].

• To the OP: other ways to separate the real and imaginary parts are these: Transpose[{Re[roots], Im[roots]}] and {Re[#], Im[#]}& /@ roots. – Szabolcs May 13 '13 at 14:23

There is actually a function in Mathematica designed for plotting the roots of polynomials. It's called RootLocusPlot and it plots the roots of a collection of polynomials parameterized by a parameter k. This can be used as follows:

poly = s^4 + k s;
RootLocusPlot[k Ratios[CoefficientList[poly, k]], {k, 0, 1}]


where I've defined the polynomial and let k vary from 0 to 1. The output of the function is What you are seeing is that when k=0 all four roots are at the origin. As k increases, one stays at the origin and the other three move out towards their final places (where the dots are) at k=1. As Szabolcs suggests, it might be a bit hard to find this function, because it is commonly used by control engineers to examine the stability of systems (which depends on the roots of polynomials). Nonetheless, the second example in the help file under Applications shows how it can be used (as above) for regular polynomials.

As Suba Thomas points out in the comments, you could also use the syntax:

RootLocusPlot[1/poly, {k, 0, 1}, FeedbackType -> None]


to get the same plot.

• It's disguised as a control systems thing though. – Szabolcs May 13 '13 at 14:22
• I have gained different point of view. I have studied numeric computitions with regard to r- bonacci polynomials. The function is getting bigger, find the function is hard seem. İnteresting viewpoint – user2444 May 16 '13 at 12:36
• @bill s or you could just do RootLocusPlot[1/poly, {k, 0, 1}, FeedbackType -> None] – Suba Thomas May 21 '13 at 14:37

Why should one have to separate out the real and imaginary parts of the roots in order to plot them as points in the complex plane? You don't, if you use David Park's Presentations add-on (http://home.comcast.net/~djmpark/DrawGraphicsPage.html):

f[z_] := z^4 + z
roots = z /. Solve[f[z] == 0, z]

<<Presentations

Draw2D[{PointSize[Large], Red, ComplexPoint /@ roots},
Axes -> True, PlotRange -> ComplexPlotRange[-1.25 - 1.25 I, 0.75 + I]] If you want to add a line segment from the origin to each root, do so as follows (where I've changed from axes to a frame so as not to obscure one of the lines):

Draw2D[{PointSize[Large], Red, ComplexPoint /@ roots,
Blue, ComplexLine[{#, 0}] & /@ roots},
Frame -> True, PlotRange -> ComplexPlotRange[-1.25 - 1.25 I, 0.75 + I]] • I know this web site thank a lot. This method can be useful – user2444 May 16 '13 at 12:28

You can use the new in M12 function ComplexListPlot:

f[x_] := x^4 + x;
ComplexListPlot[
x /. Solve[f[x] == 0, x],
PlotStyle -> PointSize[Large]
]
` 