How can I find the roots for $x^4-18x^2-8x+21$ in a nice form?
Your equation seems to be a casus irreducibilis; the solutions cannot be expressed using only real numbers.
You can make them "nicer" by using Root
objects (try RootReduce
).
RootReduce@Solve[x^4 - 18 x^2 - 8 x + 21 == 0, x]
{{x -> Root[21 - 8 #1 - 18 #1^2 + #1^4 &, 1]}, {x -> Root[21 - 8 #1 - 18 #1^2 + #1^4 &, 2]}, {x -> Root[21 - 8 #1 - 18 #1^2 + #1^4 &, 3]}, {x -> Root[21 - 8 #1 - 18 #1^2 + #1^4 &, 4]}}
Or, you can use N
and Chop
to get arbitrary-precision real numbers.
Chop@N@Solve[x^4 - 18 x^2 - 8 x + 21 == 0, x]
{{x -> -3.80007}, {x -> -1.42412}, {x -> 0.896691}, {x -> 4.3275}}
To make the radical representation explicitly real, use the TargetFunctions
option with ComplexExpand
roots = Solve[x^4 - 18 x^2 - 8 x + 21 == 0, x] //
ComplexExpand[#, TargetFunctions -> {Abs, Arg}] &
(* {{x ->
-Sqrt[3 + 4*Cos[(1/3)*ArcTan[
Sqrt[39]/5]]] -
(1/2)*Sqrt[24 -
16*Cos[(1/3)*ArcTan[
Sqrt[39]/5]] -
8/Sqrt[3 + 4*Cos[(1/3)*
ArcTan[Sqrt[39]/5]]]]},
{x ->
-Sqrt[3 + 4*Cos[(1/3)*ArcTan[
Sqrt[39]/5]]] +
(1/2)*Sqrt[24 -
16*Cos[(1/3)*ArcTan[
Sqrt[39]/5]] -
8/Sqrt[3 + 4*Cos[(1/3)*
ArcTan[Sqrt[39]/5]]]]},
{x ->
Sqrt[3 + 4*Cos[(1/3)*ArcTan[
Sqrt[39]/5]]] -
(1/2)*Sqrt[24 -
16*Cos[(1/3)*ArcTan[
Sqrt[39]/5]] +
8/Sqrt[3 + 4*Cos[(1/3)*
ArcTan[Sqrt[39]/5]]]]},
{x ->
Sqrt[3 + 4*Cos[(1/3)*ArcTan[
Sqrt[39]/5]]] +
(1/2)*Sqrt[24 -
16*Cos[(1/3)*ArcTan[
Sqrt[39]/5]] +
8/Sqrt[3 + 4*Cos[(1/3)*
ArcTan[Sqrt[39]/5]]]]}} *)
roots // N
(* {{x -> -3.80007}, {x -> -1.42412}, {x -> 0.896691}, {x -> 4.3275}} *)
You can obtain Root
objects with
Solve[x^4 - 18 x^2 - 8 x + 21 == 0, x] // FullSimplify
or
Solve[x^4 - 18 x^2 - 8 x + 21 == 0, x] // RootReduce
but numerical roots are perhaps easier to understand.
NRoots[x^4 - 18 x^2 - 8 x + 21 == 0, x]
Convert the output of NRoots
with ToRules
, and pick the real roots with Cases
. Plot the equation with red real roots. I wish I had Manipulate
when I was studying calculus.
Manipulate[
Module[{r = Cases[x/.{ToRules[NRoots[x^4 + a x^2 + b x + c == 0, x]]},_Real]},
Plot[
x^4 + a x^2 + b x + c, {x, -5, 5},
PlotLabel -> ToString@TraditionalForm[x^4+a x^2+b x+c]<>"=0\n roots \[Rule] "<>ToString[r],
Epilog -> {Red, PointSize[0.02], Point[Thread[List[r, 0]]]},
Frame -> True, BaseStyle -> {FontSize -> 16}, ImageSize -> 550]],
{{a, -18.}, -20, 20, Appearance -> "Labeled"},
{{b, -8.}, -20, 20, Appearance -> "Labeled"},
{{c, 21.}, -100, 100, Appearance -> "Labeled"}]