<s>[INST] How to find the roots of a cubic polynomial? All of the examples on the internet I could find are made so that you can somehow make the cubic equation into a first degree polynomial multiplied by a second degree polynomial. But what if you can't do that?
For example, how would you find the roots of the following equation:
$x^3+7x^2+16x+12=0$
I know the roots are $-2$, $-2$ and $-3$ but don't know how to get them.
If I somehow guess them, is there a way to tell which one is the double root?
 [/INST] While there is a rather nice test for whether a cubic polynomial has a triple zero by inspecting its coefficients (it will even tell us directly the value of that root), there is not anywhere near as simple a method for testing for a double zero by using the coefficients.  (It can be managed, but the calculations do not just require basic arithmetic.)
We can produce a straightforward method of testing with the coefficients if we suspect that a double zero is present.  We would write for the polynomial $ \ ax^3 + bx^2 + cx + d \ = \ a · (x - r)^2 · (x - s) \ \ , $ with $ \ r \ $ being the double zero and $ \ s \ $ being the other (real) zero.  This alone is not especially helpful, but we could express the "singleton" zero as $ \ s = \sigma · r \ \ . $  This then gives us
$$ a · (x - r)^2 · (x \ - \ \sigma · r) \ \ = \ \ a · ( x^3 \ - \ [ \ 2r \ + \ \sigma · r \ ]· x^2 \ + \ [ \ r^2 \ + \ 2·\sigma·r^2 \ ]·x \ - \ \sigma·r^3 \ \ . $$
The relation among the coefficients will thus be
$$ \frac{b}{a} \ = \  -r · (\sigma \ + \ 2) \ \ , \ \ \frac{c}{a} \ = \  r^2 · (1 \ + \ 2·\sigma) \ \ , \ \ \frac{d}{a} \ = \  -\sigma · r^3 \ \ . $$
This can be helpful for integer and "reasonably simple" rational coefficients.  For your example polynomial $ \ x^3 + 7x^2 + 16x + 12 \ \ , $ the fact that the constant coefficient can be factored as $ \ 12 = 2^2 · 3 \ $ might lead us to check for a double zero.  We could have either $ \ \frac{d}{a} \ = \  12 \ = \ - \ 2^2 · (-3) \ \ $ or $ \ -(-2)^2 · (-3) \ \ . $  The Rule of Signs  will tell us which of the two factorizations would be the one to try, but we will see that this test also leaves no sign ambiguity:
$$  \mathbf{r = 2 \ , \ \sigma = -\frac32 \ \ :} \quad  \frac{b}{a} \ = \  -2 · \left(-\frac32 \ + \ 2 \right) \  =  \ -1  \ \ , \ \ \frac{c}{a} \ = \  2^2 · \left(1 \ + \ 2·\left[-\frac32 \right] \right) \  =  \  -8 \ \ ;  $$
$$  \mathbf{r = -2 \ , \ \sigma = \frac32 \ \ :} \quad  \frac{b}{a} \ = \  2 · \left(\frac32 \ + \ 2 \right) \  =  \ 7  \ \ , \ \ \frac{c}{a} \ = \  (-2)^2 · \left(1 \ + \ 2·\frac32  \right) \  = \   16 \ \ .  $$
Hence, the zeroes are $ \ x \ = \ -2 \ [\text{multiplicity} \ 2] \ , \ -3 \ \ $ or $ \ x^3 + 7x^2 + 16x + 12 \ = \ (x + 2)^2 · (x \ + \ \frac32 · 2) \ = \ (x + 2)^2 · (x  +  3) \ \ . $
As an additional demonstration, we could attempt to solve in this manner $ \ 9x^3 + 3x^2 - 56x + 48 \ = \ 0  \ : $
$$ \frac{d}{a} \ = \  \frac{48}{9} \  = \  \frac{16}{3} \ = \ - \left(\frac43 \right)^2 · (-3) \ \ \ [?]  $$
(the Rule of Signs tells us there would be one negative zero and two positive real zeroes) so we will want to check $ \  r = \frac43 \ , \ \sigma = -\frac94 \ \ : $
$$ \rightarrow \ \     \frac{b}{a} \ = \  -\frac43 · \left(-\frac94 \ + \ 2 \right) \  =  \ \frac13  \ \ , \ \ \frac{c}{a} \ = \  \left(\frac43 \right)^2 · \left(1 \ + \ 2·\left[-\frac94 \right] \right) \  =  \  -\frac{56}{9} \ \ .  $$
We do have $ \ b = \frac93 = 3 \ $ and $ \ c = -56 \ \ , $ which permits us to conclude that
$$    9x^3 + 3x^2 - 56x + 48 \ \ = \ \ 9 · \left( x - \frac43 \right)^2 · \ (x + 3 ) \ \ . $$
Naturally, if this coefficient test indicates that we do not have a double zero, we will need to "fall back" to more elaborate methods to determine the zeroes.
</s>