# How to obtain exact answers for casus irreducibilis for third order equation in Mathematica

According to https://en.wikipedia.org/wiki/Cubic_equation#General_cubic_formula When a cubic equation with real coefficients has three real roots, the formulas expressing these roots in terms of radicals involve complex numbers. Galois theory allows proving that when the three roots are real, and none is rational (casus irreducibilis), one cannot express the roots in terms of real radicals. Nevertheless, purely real expressions of the solutions may be obtained using trigonometric functions, specifically in terms of cosines and arccosines, by Vieta's formulas.

\$Version

(* "13.0.0 for Mac OS X x86 (64-bit) (December 3, 2021)" *)

Clear["Global*"]

eqn = t^3 + p*t + q == 0;

solRad = Assuming[4 p^3 + 27 q^2 < 0,
Solve[eqn, t] // ToRadicals // Simplify]

(* {{t -> (-2 3^(1/3) p + 2^(1/3) (-9 q + Sqrt[12 p^3 + 81 q^2])^(2/3))/(
6^(2/3) (-9 q + Sqrt[12 p^3 + 81 q^2])^(1/3))},
{t -> (2 2^(1/3) 3^(1/6) (3 I + Sqrt[3]) p +
I 2^(2/3) 3^(1/3) (I + Sqrt[3]) (-9 q + Sqrt[12 p^3 + 81 q^2])^(2/3))/(
12 (-9 q + Sqrt[12 p^3 + 81 q^2])^(1/3))},
{t -> (2 2^(1/3) 3^(1/6) (-3 I + Sqrt[3]) p +
2^(2/3) 3^(1/3) (-1 - I Sqrt[3]) (-9 q + Sqrt[12 p^3 + 81 q^2])^(2/3))/(
12 (-9 q + Sqrt[12 p^3 + 81 q^2])^(1/3))}}


Verifying the solution,

Assuming[4 p^3 + 27 q^2 < 0, eqn /. solRad // Simplify]

(* {True, True, True} *)


To convert to trig expressions use ComplexExpand with the option TargetFunctions set to {Re, Im}

solTrig = Assuming[4 p^3 + 27 q^2 < 0,
solRad // ComplexExpand[#, TargetFunctions -> {Re, Im}] & // Simplify]

(* {{t -> (2 Sqrt[-p] Cos[1/3 ArcTan[-9 q, Sqrt[-12 p^3 - 81 q^2]]])/Sqrt[
3]},
{t -> -(1/3)
Sqrt[-p] (Sqrt[3] Cos[1/3 ArcTan[-9 q, Sqrt[-12 p^3 - 81 q^2]]] +
3 Sin[1/3 ArcTan[-9 q, Sqrt[-12 p^3 - 81 q^2]]])},
{t -> -(1/3)
Sqrt[-p] (Sqrt[3] Cos[1/3 ArcTan[-9 q, Sqrt[-12 p^3 - 81 q^2]]] -
3 Sin[1/3 ArcTan[-9 q, Sqrt[-12 p^3 - 81 q^2]]])}} *)


Plotting,

Plot3D[Evaluate[t /. solTrig],
{p, q} ∈ ImplicitRegion[4 p^3 + 27 q^2 < 0, {p, q}],
PlotLegends -> Automatic,
PlotPoints -> 100,
MaxRecursion -> 5]
`