0
$\begingroup$

I have three polynomials, first one is of degree 5, second one is of degree 5 and the last one is of degree 4. I want to locate the zeros (only the points on the real line) of these polynomials in one graph. How to draw the graph taking different colors for each? Please help me. Thanking you in advance.

$\endgroup$
  • $\begingroup$ show us the polynomials, then show us the code you have come up with so far. For polynomials, you should try NSolve[polynomialInX, x, Reals]. You can also run a search on this site: the topic of finding all roots has been discussed in detail in the past. $\endgroup$ – MarcoB May 9 '18 at 14:31
  • $\begingroup$ a possibilty : Plot[poly, {x, -10, 17},MeshFunctions->{#2&},Mesh-> {{0.}},MeshStyle->Directive[PointSize[0.03],Red]] $\endgroup$ – andre314 May 9 '18 at 18:06
3
$\begingroup$

Here is an example to get you started:

poly = -1680 + 548 x - 292 x^2 + 153 x^3 + 22 x^4 - 2 x^5;
zeroes = {x, 0} /. NSolve[poly == 0, x, Reals];

Plot[
  poly, {x, -10, 17},
  Epilog -> {Red, PointSize[0.03], Point[zeroes]}
]

just points


You can also label the zeroes with their abscissa value:

Show[
  Plot[poly, {x, -10, 17}],
  ListPlot[
    Callout[#, Style[Round[#[[1]], 0.1], Red, 14]] & /@ zeroes,
    PlotStyle -> Directive[Red, PointSize[0.03]]
  ]
]

callouts

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks a lot. Now I am able to locate the zeros of 3 polynomials at a time. Is there any command to locate only the zeros of the polynomials? (I mean I don't want the curves, I need only points on the real axis.) $\endgroup$ – Pinaki Prasad Kar May 13 '18 at 8:41
  • $\begingroup$ That’s what the ‘zeroes’ expression already does, more or less. You could try: zero1d = x /. NSolve[poly == 0, x, Reals] and then use NumberLinePlot[zero1d]. $\endgroup$ – MarcoB May 13 '18 at 15:15

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