Here is the general cubic, with the $x^3$ coefficient already divided into the other coefficients, right hand side already set to zero because we are finding roots: $x^3+ax^2+bx+c=0$.
We substitute in $x=y-\frac{a}{3}$ to get $$\begin{aligned} \left(y^3 - \frac{2a}{3}y^2 + \frac{a^2}{9}y - \frac{a}{3}y^2 + \frac{2a^2}{9}y - \frac{a^3}{27}\right)& \\ + a\left(y^2 - \frac{2a}{3}y + \frac{a^2}{9}\right)& \\ + b\left(y - \frac{a}{3}\right)& \\ + c = 0 \end{aligned}$$ Simplifying to give $$\begin{aligned} y^3 \color{blue}{- ay^2} \color{bluegreenish}{+ \frac{a^2}{3}y} \color{green}{- \frac{a^3}{27}}& \\ \color{blue}{+ ay^2} \color{bluegreenish}{- \frac{2a^2}{3}y} \color{green}{+ \frac{a^3}{9}}& \\ \color{bluegreenish}{+ by} \color{green}{- \frac{ab}{3}}& \\ \color{green}{+c} &= 0 \end{aligned}$$ Simplifying more to give $$y^3 - \frac{a^2}{3}y + by - \frac{a^3}{27} + \frac{a^3}{9} - \frac{ab}{3} + c = 0$$
This is of the form $y^3+dy+e=0$ where $$d=b-\frac{a^2}{3} \text{ and } e= - \frac{a^3}{27} + \frac{a^3}{9} - \frac{ab}{3} + c$$
We substitute $y=\sqrt[3]{u}-\sqrt[3]{v}$ to get $$\sqrt[3]{u}^3 - 3 \sqrt[3]{u}^2 \sqrt[3]{v} + 3 \sqrt[3]{u} \sqrt[3]{v}^2 - \sqrt[3]{v}^3 + d\sqrt[3]{u} - d\sqrt[3]{v} + e = 0$$
Simplifying to get $$(u - v) - d\sqrt[3]{v} - 3 \sqrt[3]{u}^2 \sqrt[3]{v} + d\sqrt[3]{u} + 3 \sqrt[3]{u} \sqrt[3]{v}^2 + e = 0$$
Anti-distributing to get $$(u - v) - \sqrt[3]{v}(d - 3 \sqrt[3]{u}^2) + \sqrt[3]{u}(d + 3 \sqrt[3]{v}^2) + e = 0$$
Let's define $\color{purple}{v-u=e}$ ('cause we can), causing $- \sqrt[3]{v}(d - 3 \sqrt[3]{u}^2) + \sqrt[3]{u}(d + 3 \sqrt[3]{v}^2) = 0$, which can be simplified to
$$\begin{aligned} \sqrt[3]{u}(d + 3 \sqrt[3]{v}^2) &= \sqrt[3]{v}(d + 3 \sqrt[3]{u}^2) \\ d\sqrt[3]{u} + 3\sqrt[3]{u}\sqrt[3]{v}^2 &= d\sqrt[3]{v} + 3\sqrt[3]{v}\sqrt[3]{u}^2 \\ d\sqrt[3]{u}-d\sqrt[3]{v} &= 3 \sqrt[3]{v} \sqrt[3]{u}^2 - 3 \sqrt[3]{u} \sqrt[3]{v}^2 \\ d(\sqrt[3]{u}-\sqrt[3]{v}) &= 3 \sqrt[3]{v}\sqrt[3]{u}(\sqrt[3]{u} - \sqrt[3]{v}) \\ d &= 3 \sqrt[3]{v}\sqrt[3]{u} \\ \frac{d}{3} &= \sqrt[3]{uv} \\ \color{purple}{\frac{d^3}{27}} &\color{purple}{= uv} \end{aligned}$$
From the first purple equation, we have $v=e+u$, which we can put into the second to get $$u(e+u)=\frac{d^3}{27} \to u^2 + eu - \frac{d^3}{27}=0$$ Where we can solve for $u$ with the quadratic formula. $$u=\frac{-e\pm\sqrt{e^2+4\frac{d^3}{27}}}{2}$$
We can also get equations for $v$; the first equation gives $u=v-e$, which we stuff into the second equation to get $$v(v-e)=\frac{d^3}{27} \to v^2 - ev - \frac{d^3}{27}$$ Quadratic formula yielding $$v=\frac{e\pm\sqrt{e^2+4\frac{d^3}{27}}}{2}$$
Via our definition above $(y=\sqrt[3]{u}-\sqrt[3]{v})$, we get $$y=\sqrt[3]{\frac{-e\pm\sqrt{e^2+4\frac{d^3}{27}}}{2}}-\sqrt[3]{\frac{e\pm\sqrt{e^2+4\frac{d^3}{27}}}{2}}$$ And from the definition above that $(x=y-\frac{a}{3})$, we have $$x=\sqrt[3]{\frac{-e\pm\sqrt{e^2+4\frac{d^3}{27}}}{2}}-\sqrt[3]{\frac{e\pm\sqrt{e^2+4\frac{d^3}{27}}}{2}}-\frac{a}{3}$$
Okay, now that I had that, I went to Desmos and graphed a general cubic with points at the roots of the cubic as calculated from this formula, here, where I replaced the variable e from above with f: https://www.desmos.com/calculator/fqnobwyfmp.
Here is the Wolfram Mathematica code:
"Coefficients"
a=3
b=-1
c= 0
"Variables"
d=ToExpression["b-\frac{a^2}{3}",TeXForm]
f=ToExpression["-\frac{a^3}{27}+\frac{a^3}{9}-\frac{a*b}{3}+c", TeXForm]
g=ToExpression["f^2+\frac{4*d^3}{27}", TeXForm]
"u"
u=ToExpression["\frac{-f+\sqrt{g}}{2}", TeXForm]
m1=Re[u]
n1=Im[u]
r1=Sqrt[m1^2+n1^2]
t1=Limit[ArcTan[n1/k],k->m1]
w=CubeRoot[r1](Cos[t1/3]+ISin[t1/3])
"v"
v=ToExpression["\frac{f+\sqrt{g}}{2}", TeXForm]
m=Re[v]
n=Im[v]
r=Sqrt[m^2+n^2]
t=Limit[ArcTan[n/l],l->m]
z=CubeRoot[r](Cos[t/3]+ISin[t/3])
"Roots of unity"
p=-1/2 + ISqrt[3]/2
q=-1/2 - ISqrt[3]/2
"y"
If[w==0,y1=w-z, y1=w-d/(3*w)]
If[w==0,y2=pw-qz, y2=pw-qd/(3*w)]
If[w==0,y3=qw-pz,y3=qw-pd/(3*w)]
"x"
x1=y1-a/3
Style[Simplify[%],FontSize->30]
x2=y2-a/3
Style[Simplify[%],FontSize->30]
x3=y3-a/3
Style[Simplify[%],FontSize->30]
Data={{Re[x1],0},{Re[x2],0},{Re[x3],0}}
Show[Plot[{x^3+ax^2+bx+c},{x,-5,5},PlotRange->15], Graphics[{PointSize[Medium], Red, Point[Data]}]]
Here are my questions:
When I have one root, Roots 1 and 4 are on the right point, but Root 2 and Root 3 are somewhere unrelated. Where do the values of Roots 2 and 3 come from?
When I have more than one root, the quadratic formulas yield imaginary numbers, when clearly there are real roots. Why? Did I do something wrong in my derivation?
Clearly my cubic formula completely failed. What happened? How do I know which of the 4 possible roots are actually roots?
Thanks for any help! I know it was a lot to read.