# How to draw the graph of zeros of a polynomial in Mathematica? [closed]

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.

## closed as off-topic by Bob Hanlon, Coolwater, MarcoB, Henrik Schumacher, chuyMay 9 '18 at 18:01

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." – Bob Hanlon, Coolwater, MarcoB, Henrik Schumacher, chuy
If this question can be reworded to fit the rules in the help center, please edit the question.

• 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. – MarcoB May 9 '18 at 14:31
• a possibilty : Plot[poly, {x, -10, 17},MeshFunctions->{#2&},Mesh-> {{0.}},MeshStyle->Directive[PointSize[0.03],Red]] – andre314 May 9 '18 at 18:06

## 1 Answer

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]}
] You can also label the zeroes with their abscissa value:

Show[
Plot[poly, {x, -10, 17}],
ListPlot[
Callout[#, Style[Round[#[], 0.1], Red, 14]] & /@ zeroes,
PlotStyle -> Directive[Red, PointSize[0.03]]
]
] • 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.) – Pinaki Prasad Kar May 13 '18 at 8:41
• 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]. – MarcoB May 13 '18 at 15:15