I've Hit a Major Snag While Writing a Paper on Deriving the Cubic Formula!

The formula for $x$ and $z$ in the link is

$$ x = z - \frac{p}{3z} - \frac{b}{3a} \qquad \text{and}\qquad z = \sqrt[3]{-\frac{q}{2} \pm \sqrt{D}}, $$

where $p$, $q$, and $D$ are defined by

$$ p = -\frac{b^2}{3a^2} + \frac{c}{a}, \qquad q = \frac{2b^3}{27a^3} - \frac{bc}{3a^2} + \frac{d}{a}, \qquad\text{and}\qquad D = \frac{q^2}{4} + \frac{p^3}{27}. $$

Applying this to $-2x^3+3x^2-x+5=0$, we obtain

$$ p = -0.25, \qquad q = -2.5, \qquad D \approx 1.56192. $$

Then the six possible values of $z$, denoted by

$$ z_{k,\pm} = e^{2k\pi i/3} \sqrt[3]{-\frac{q}{2} \pm \sqrt{D}}, $$

are given by

\begin{align*} z_{0,+} &\approx 1.35717 & \Rightarrow \quad x &\approx 1.91857, \\ z_{1,+} &\approx -0.678583 + 1.17534 i & \Rightarrow \quad x &\approx -0.209285 + 1.12216 i, \\ z_{2,+} &\approx -0.678583 - 1.17534 i & \Rightarrow \quad x &\approx -0.209285 - 1.12216 i, \\ z_{0,-} &\approx 0.0614024 & \Rightarrow \quad x &\approx 1.91857, \\ z_{1,-} &\approx -0.0307012 + 0.0531761 i & \Rightarrow \quad x &\approx -0.209285 - 1.12216 i, \\ z_{2,-} &\approx -0.0307012 - 0.0531761 i & \Rightarrow \quad x &\approx -0.209285 + 1.12216 i. \\ \end{align*}

So I suspect that you made some mistakes. Note that, when computing $z_{k,-}$'s, you have to work with the expression

$$ -\frac{q}{2} - \sqrt{D} $$

where

$$-\frac{q}{2} = 1.25 \qquad\text{and}\qquad \sqrt{D} \approx 1.2497684970810779307.$$

Since these values are very close, their difference leads to the loss of several significant digits. For instance, if we use six digits, then

$$ -\frac{q}{2} - \sqrt{D} \approx (1.25) - (1.24977) = 0.00023, $$

losing four digits in the process! Now, given that you are working under only three significant digits, you will almost certainly lose all the significant digits in this process, ending up with quantities dominated by rounding errors. I strongly suspect that this is the source of your incorrect answer.


You start something of the form:

$z = \sqrt [3] {A \pm \sqrt {A^2+B^3}}\\ x = z - \frac {B}{z} -\frac {b}{3a}$

Lets choose $z = \sqrt [3] {A + \sqrt {A^2+B^3}}$ and let $\bar z = \sqrt [3] {A - \sqrt {A^2+B^3}} $ represent the conjugate (option with the negative sign).

Then

$z-\frac {B}{z} = z-\frac {B}{\sqrt [3] {A + \sqrt {A^2+B^3}}}\frac {\sqrt [3] {A - \sqrt {A^3+B^2}}}{\sqrt [3] {A - \sqrt {A^2+B^3}}} = z-\frac {B\sqrt [3] {A^2 - {A^2+B^3}}}{\sqrt [3] {A^2 - (A^2+B^3)}} = z + \sqrt [3] {A - \sqrt {A^2+B^3}} = z + \bar z$

And if you transpose $z$ and $\bar z$ you get something identical.

$x = (e^{\frac {2\pi}3i})^k\sqrt[3]{\frac{9abc-2b^3-27a^2d}{54a^3}+\sqrt{\frac{4ac^3+27a^2d^2-18abcd-b^2c^2+b^3d}{108a^4}}} + (e^{\frac {-2\pi}3i})^k\sqrt[3]{\frac{9abc-2b^3-27a^2d}{54a^3}-\sqrt{\frac{4ac^3+27a^2d^2-18abcd-b^2c^2+b^3d}{108a^4}}} - \frac {b}{3a}$