I'm currently trying to calculate zeros of a cubic function using the Cardano formula
I somehow miscalculated really bad and I suspect that I've done a really cheap beginners mistake. I searched but I wasn't able to find my mistake
I only get 2 results with instead of 3 and the values are also off
I know that the cardanian formula isn't very exact especially when you round some values- which I did.
Cardano's method requires the reduced function
(sorry if this i not the correct term but I don't know the correct english name)
I tried to solve this very simple cubic function:
$ 2x^3 + 4x^2 - 2x - 4 $
reduced function:
$ z^3 - pz + q = 0$
$ z^3 - - 2 \frac{1}{3}z + \frac{-20}{27} = 0$
This is cardanos method: \begin{equation*} z=\sqrt[3]{-\frac q 2+\sqrt{(\frac q 2)^2+\frac{p^3}{27}}}+\sqrt[3]{-\frac q 2-\sqrt{(\frac q 2)^2+\frac{p^3}{27}}} \end{equation*}
and I just put my values in and tried calculating it
\begin{equation*}z=\sqrt[3]{-\frac{\frac{-20}{27}} 2+\sqrt{\left(\frac{\frac{-20}{27}} 2\right)^2+\frac{\left(-2\frac 1 3\right)^3}{27}}}+\sqrt[3]{-\frac{\frac{-20}{27}} 2-\sqrt{\left(\frac{\frac{-20}{27}} 2\right)^2+\frac{\left(-2\frac 1 3\right)^3}{27}}}\end{equation*}\begin{equation*}z=\sqrt[3]{\frac{10}{27}+\sqrt{\left(\frac{-10}{27}\right)^2+\frac{-343}{729}}}+\sqrt[3]{\frac{10}{27}-\sqrt{\left(\frac{-10}{27}\right)^2+\frac{-343}{729}}}\end{equation*}\begin{equation*}z=\sqrt[3]{\frac{10}{27}+\sqrt{\frac{-1} 3}}+\sqrt[3]{\frac{10}{27}-\sqrt{\frac{-1} 3}}\end{equation*}\begin{equation*}z=\sqrt[3]{\frac{10}{27}+(\pm 0,5774)}+\sqrt[3]{\frac{10}{27}-(\pm 0,5774)}\end{equation*}
These are the two possible solutions:
\begin{equation*}z_1=\sqrt[3]{\frac{10}{27}+0,5774}+\sqrt[3]{\frac{10}{27}-0,5774}\end{equation*}\begin{equation*}z_1=\sqrt[3]{0,98226}+\sqrt[3]{-0,59152}\end{equation*}\begin{equation*}z_1=0,99405-0,83944\end{equation*}\begin{equation*}z_1=1,8335\end{equation*}
\begin{equation*}z_2=\sqrt[3]{\frac{10}{27}-0,5774}+\sqrt[3]{\frac{10}{27}+0,5774}\end{equation*}\begin{equation*}z_2=\sqrt[3]{-0,59152}+\sqrt[3]{0,98226}\end{equation*}\begin{equation*}z_2=0,83944-0,99405\end{equation*}\begin{equation*}z_2=-0.15461\end{equation*}
I used this online calculator to calculate the zeros but got a totally diffrent valus that my cardanos method results. The calculator says that the graph has 3 zero points at $-2$,$-1$ and $1$.
I think I've made a very embarrassing mistake somewhere.
I know that cardanos method isn't very useful from todays perspective but I need to turn in an work on thus very soon and I'm pretty much done except with these example calculations.
I hope you guys are able to help me :)
Thanks for reading. Have a nice day
Cardano's formula won't work here, as this equation has $3$ real roots. If you examine the way this formula is obtained, you'll see it comes down to finding two numbers when their product and sum are given. This is a typical problem of quadratic equations, and it has solutions if the discriminant of the quadratic equation is non-negative.
Now it happens that, when the cubic equation has $3$ real roots, this discriminant is negative,. The formula remains true, but you have to consider a real number has $3$ complex cubic roots, of which one is real. Actually this case was the reason for introducing complex numbers at the time.
In such a case, a trigonometric resolution is much more efficient. For your equation this isn't even necessary, as it is enough to do partial factorisations to find the roots: $$2x^3+4x^2-2x-4=2x(x^2-1)+4(x^2-1)=2(x-1)(x+1)(x+2).$$