Theres plenty of great answers here but I have some similar ideas I can give you..Maybe not as elegant or as advanced as others but it is straightforward.
Clear[f, roots]
f[x_] := x^4 - 18 x^2 - 8 x + 21
I would recommend NSolve because it is a numerical approximation, whereas Solve is solving it explicitly
roots = NSolve[f[x] == 0, x]
={{x -> -3.80007}, {x -> -1.42412}, {x -> 0.896691}, {x -> 4.3275}}
Checks that roots are right
f[x] /. roots//Chop
={0, 0, 0, 0}
I don't think this offers anymore assistance than what is already here, but oh well. You could even plot some of the roots on a graph of the curve..Say the 1st and 4th root..
Clear[x1, x2];
x1 = x /. roots[[1]];
x2 = x /. roots[[4]];
Clear[curve];
curve = Plot[f[x], {x, -6, 6},
AxesLabel -> {"x", "y"}, Ticks -> None, BaseStyle -> {18, FontFamily -> "Georgia"}];
PtLabel1 = Graphics[Text["( " <> ToString[x1] <> "," <> ToString[f[x1]] <> ")", {x1, f[x1] + 50}]];
PtLabel2 = Graphics[Text["( " <> ToString[x2] <> "," <> ToString[f[x2]] <> ")", {x2, f[x2] + 50}]];
pt1 = Graphics[{PointSize[0.02`], Point[{x1, f[x1]}]}];
pt2 = Graphics[{PointSize[0.02`], Point[{x2, f[x2]}]}];
Show[curve, PtLabel1, PtLabel2, pt1, pt2]
Root
objects. If you applyN
to the result (andChop
them), you will get a real number. $\endgroup$