<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] The trick is transforming the general cubic equation into a new cubic equation with missing $x^2$ term is due to
Nicolo Fontana Tartaglia.  
Apply the substitution
$$ x = y - \frac{b}{3a} $$
then we get 
$$ a\left(y-\frac{b}{3a} \right)^3 + b\left(y-\frac{b}{3a} \right)^2+c\left(y-\frac{b}{3a} \right)+d = 0 $$
which simplifies to
$$ ay^3 + \left( c-\frac{b^2}{3a}\right)y+ \left(d + \frac{2b^3}{27a^2} - \frac{bc}{3a} \right) = 0 $$
This is called a depressed cubic equation, because the square term is eliminated.  It is much easier to use this and then
find the roots. (back substitute to get the roots in terms of $x$)
For example $$2x^3-18x^2+46x-30=0$$
Substitute $ x=y+3$ and simplify this cubic equation to
$2y^3-8y=0 \Rightarrow y=0,2,-2$ which then gives the roots as
$x=1,3, $ and $5$.
</s>