<s>[INST] Finding root of a polynomial Let's say I've got $ax^3 + bx^2 + cx + d = 0$
I want to find x for a general-case.
Mathematica gave me a very long solution, and even longer for one which has $kx^4$.
Can you please help me reproduce the algorithm used by Mathematica to generate formula of:
$$P(x) = a_0x^0 + a_1x^1 + a_2x^2 + a_3x^3 + \cdots+ a_nx^n$$
i.e., general case of a polynomial.
 [/INST] Here's a (standard) method to treat the cubic case, though it hides some of what is going on, which is basically Galois Theory. You might as well suppose that $a \neq 0$ (otherwise you would be dealing with a quadratic at worse). Hence you can divide through and assume that $a = 1.$ So let's work instead with the cubic $x^3 + ax^2 + bx + c.$ Now set $y = x + \frac{a}{3}.$ Then $x^3 + ax^2 + bx + c$ has the form $y^3 + ey + f,$ and if we can solve for $y,$ we can easily recover $x$ (the constants $e$ and $f$ can be calculated routinely in terms of $a,b$ and $c,$ but we omit the rather tedious details. Hence if we can solve equations of the form $x^3 + ax + b =0,$ we can deal with the general cubic, and we may as well suppose that $b \neq 0,$ for the case $b =0$ is easy.  To solve the equation $x^3 + ax + b = 0$ when $b \neq 0$,  set $x = u+v.$ The equation may then be written as
$(u^3 + v^3) + b + (u+v)(3uv+a) = 0.$ We can try to solve separately, but simultaneously, $(u+v)(3uv+a) = 0$ and $u^3 +v^3 = -b.$ Note that $u +v \neq 0$ since $b \neq 0,$ so we need $uv = -\frac{a}{3}$ and $u^3 + v^3 = -b.$ Hence $(t -u^3)(t-v^3) = t^2 +bt -\frac{a^3}{27}$, and two solutions do have a simultaneous solution, with $u^3$ and $v^3$ being the roots of a quadratic.
</s>