# Calculate and plot the roots of a polynomial?

Posted 2 months ago
247 Views
|
3 Replies
|
0 Total Likes
|
 Hi, on mathematica I have represented the following polynomial a * x ^ 4 + b * x ^ 2 + c * x + 2 using the "Plot" command and, through the "Manipulate" command, it is possible to vary the parameters a, b, c. Now, however, I would like the program to give me back the roots of the polynomial according to the parameters a, b, c .... could you help me kindly?This is the code: Manipulate[ Plot[a*x^4 + b*x^2 + c*x + 2, {x, -20, 20}, PlotRange -> {{-20, 20}, {-20, 20}}], {a, -1, 1}, {b, -10, 10}, {c, -10, 10}, ControlPlacement -> Right] 
3 Replies
Sort By:
Posted 2 months ago
 You can use Solve to find the roots. e.g. with a = 1, b = 10, c = 10. Solve[1*x^4 + 10*x^2 + 10*x + 2 == 0, x] For a numerical approximation: NSolve[1*x^4 + 10*x^2 + 10*x + 2 == 0, x] {{x -> -0.67205}, {x -> -0.277728}, {x -> 0.474889 - 3.23881 I}, {x -> 0.474889 + 3.23881 I}} 
 Pasquale,Not sure what you want to do with the roots. Here is one option if you want to show them above the plot. Manipulate[Module[{poly = a*x^4 + b*x^2 + c*x + 2}, Pane[roots = NSolve[poly == 0, x]; Column[ { Style[Column[Prepend[roots, "Roots"]], 10], Show[ Plot[poly, {x, -20, 20}, PlotRange -> {{-20, 20}, {-20, 20}}]] }, Alignment -> Center]]], {a, -1, 1}, {b, -10, 10}, {c, -10, 10}, ControlPlacement -> Right]