# Algebraic solution of a third degree polynomial equation with real coefficients

Recently I've come across an equation of the form:

$$ax^3 + bx^2 + cx + d = 0, \ where\ a,b,c,d \in \mathbb{R}$$

I'm struggling a bit to solve this algebraically. I know if we had either $$a=0$$ or $$d=0$$ then it would be a simple case of solving a quadratic equation or factoring then using quadratic equation to get our solutions. The presence of both terms seems to preclude this, unless of course, I'm missing something very simple. Any help here wuld be greatly appreciated.

• Are you aware of Cardano's formula? Mar 25, 2022 at 18:32
• A site search for cubic formula yields almost $2000$ results. Some relevant instances appear early in the list.
– Blue
Mar 26, 2022 at 5:33

$$F(x)=-f + a x + b x^2 + c x^3$$

By resultant

$$P(y)=Res_x(F(x),1 - x + S y - T x y)=\\ a + b + c - f + (3 c S - 3 f T + b (2 S + T) + a (S + 2 T)) y + ((b + 3 c) S^2 + 2 (a + b) S T + (a - 3 f) T^2) y^2 + (c S^3 + b S^2 T + a S T^2 - f T^3) y^3\\$$

$$Res_y(P(y),-z + ((b + 3 c) S^2 + 2 (a + b) S T + (a - 3 f) T^2) + 3 (c S^3 + b S^2 T + a S T^2 - f T^3) y)=\\ -(c S^3 + b S^2 T + a S T^2 - f T^3)V(z)$$

where

$$V(z)=(S - T)^3 (2 b^3 S^3 - 27 c^2 f S^3 - 2 a^3 T^3 + 3 b^2 S T (a S - 6 f T) - 3 b (a S + 3 f T) (3 c S^2 + a T^2) - 9 c T (2 a^2 S^2 - 3 a f S T + 3 f^2 T^2))\\ -3 (S - T)^2 ((b^2 - 3 a c) S^2 + (a b + 9 c f) S T + (a^2 + 3 b f) T^2)z+z^3$$

Let $$(b^2 - 3 a c) S^2 + (a b + 9 c f) S T + (a^2 + 3 b f) T^2=0$$, then $$V(z)$$ is perfect cubic.

And solution $$F(x)=0$$ is:

$$k=a b + 9 c f, m=b^2 - 3 a c, n=a^2 + 3 b f\\ \{V = \dfrac{-k + \sqrt{k^2 - 4 m n}}{2 n}, S = 1, T = V\}|| \{V = \dfrac{-k + \sqrt{k^2 - 4 m n}}{2 m}, S = V, T = 1\}\\ F = f - a - b - c\\ A = (a + 2 b + 3 c) S + (2 a + b - 3 f) T\\ B = (b + 3 c) S^2 + 2 (a + b) S T + (a - 3 f) T^2\\ Q = c S^3 + b S^2 T + a S T^2 - f T^3\\ G = -2 B^3 + 9 A B Q + 27 Q^2 F\\ H = \{G^{1/3}, -(-1)^{1/3} G^{1/3}, (-1)^{2/3} G^{1/3}\}\\ y = \dfrac{H - B}{3 Q}\\ x=\dfrac{1 + S y}{1 + T y}$$

Formula work with $$f=0$$ and/or $$c=0$$ and not work with double/triple roots.

Wolfram code for verifing:

{{f, a, b, c} = RandomInteger[{-1000, 1000}, 4];
Eq = -f + a x + b x^2 + c x^3;
Print["\nEquation: 0 = ", Eq, "\n\nSolution by CAS:"];
Print[x /. (Eq // NSolve) // Sort, "\n"];
Print["Solution by formula:"];
{k, m, n} = {a b + 9 c f, b^2 - 3 a c, a^2 + 3 b f};
If[m == 0 && n == 0,
Print["Formula does not work with double/triple roots"]; Goto[end]];
If[m == 0, V = (-k + Sqrt[k^2 - 4 m n])/(2 n); S = 1; T = V];
If[n == 0 || (m != 0 && n != 0), V = (-k + Sqrt[k^2 - 4 m n])/(2 m);
S = V; T = 1];
F = f - a - b - c;
A = (a + 2 b + 3 c) S + (2 a + b - 3 f) T;
B = (b + 3 c) S^2 + 2 (a + b) S T + (a - 3 f) T^2;
Q = c S^3 + b S^2 T + a S T^2 - f T^3;
If[Q == 0, Print["Formula does not work with double/triple roots"];
Goto[end]];
G = -2 B^3 + 9 A B Q + 27 Q^2 F;
H = {G^(1/3), -(-1)^(1/3) G^(1/3), (-1)^(2/3) G^(1/3)};
y = (H - B)/(3 Q);
Print[(1 + S y)/(1 + T y) // N // Sort];
Label[end];};


Video as work this formula.