4
$\begingroup$

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}]]
$\endgroup$
1

5 Answers 5

7
$\begingroup$

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

enter image description here

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.

$\endgroup$
3
  • $\begingroup$ It's disguised as a control systems thing though. $\endgroup$
    – Szabolcs
    Commented May 13, 2013 at 14:22
  • $\begingroup$ 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 $\endgroup$
    – user2444
    Commented May 16, 2013 at 12:36
  • $\begingroup$ @bill s or you could just do RootLocusPlot[1/poly, {k, 0, 1}, FeedbackType -> None] $\endgroup$ Commented May 21, 2013 at 14:37
6
$\begingroup$

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[6]]

roots of a polynomial

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[].

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

You can use the new in M12 function ComplexListPlot:

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

enter image description here

$\endgroup$
3
$\begingroup$

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]]

enter image description here

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]]

enter image description here

$\endgroup$
1
  • $\begingroup$ I know this web site thank a lot. This method can be useful $\endgroup$
    – user2444
    Commented May 16, 2013 at 12:28
1
$\begingroup$

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

Labeled ComplexListPlot

$\endgroup$
1
  • 1
    $\begingroup$ That's pretty much the same as Carl Woll's answer. Just a trivial difference in styling. $\endgroup$
    – Michael E2
    Commented Dec 2, 2020 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.