I think you can avoid the Newton-Raphson altogether, since cubic is solvable in radicals.
Here is the complete algorithm (working under constraints outlined in the problem), in Mathematica:
Clear[PositiveCubicRoot];
PositiveCubicRoot[p_, q_, r_] :=
Module[{po3 = p/3, a, b, det, abs, arg},
b = ( po3^3 - po3 q/2 + r/2);
a = (-po3^2 + q/3);
det = a^3 + b^2;
If[det >= 0,
det = Power[Sqrt[det] - b, 1/3];
-po3 - a/det + det
,
(* evaluate real part, imaginary parts cancel anyway *)
abs = Sqrt[-a^3];
arg = ArcCos[-b/abs];
abs = Power[abs, 1/3];
abs = (abs - a/abs);
arg = -po3 + abs*Cos[arg/3]
]
]
Then
In[222]:= PositiveCubicRoot[-2.52111798, -71.424692, -129.51520]
Out[222]= 10.499
However, if the Newton-Raphson method must be used, then a good initial guess is imperative. Binary division is a good method to isolate the root in the case at hand.
We start with an arbitrary point $x$, I chose $x=1$, and double it while the polynomial
at that point is negative. Then do binary division a certain number of times (the code below does it twice). Ultimately, polish it off with Newton-Raphson iterations:
In[283]:=
NewtonRaphsonStartingPoint[{p_, q_, r_}] := Module[{x1=0, x2=1,f1,f2,xm,fm},
f1 = r + x1 (q + (p + x1) x1);
While[(f2 = r + x2 (q + (p + x2) x2)) <= 0,
x1 = x2; f1 = f2; x2 = 2 x2];
Do[xm = (x1 + x2)/2; fm = r + xm (q + (p + xm) xm);
If[fm <= 0, f1 = fm; x1 = xm, f2 = fm; x2 = xm], {i, 2}];
(f2 x2 - f1 x1)/(f2 - f1)
];
NewtonRaphsonIterate[{p_, q_, r_}, x0_Real] :=
FixedPoint[
Function[x, x - (r + x (q + (p + x) x))/(q + (2 p + 3 x) x)], x0]
In[285]:=
NewtonRaphson[p_, q_, r_] :=
NewtonRaphsonIterate[{p, q, r}, NewtonRaphsonStartingPoint[{p, q, r}]]
In[286]:= NewtonRaphson[-2.52111798, -71.424692, -129.51520]
Out[286]= 10.499
Best Answer
You can solve cubics using a similar idea to 'completing the square'. The first step is to note that $(x+y)^3=x^3+3x^2y+3xy^2+y^3$ and use this to remove the quadratic factor. For your example, lets just factorize $x^3+4x^2+5x-3$. Once we do this we can multiply by $2$ to get the original equation. We write the equation as:
$$ \begin{split} x^3+4x^2+5x-3&=x^3+3\cdot\left(\frac{4}{3}\right)x^2+3\cdot\left(\frac{4}{3}\right)^2x+\left(\frac{4}{3}\right)^3-\frac{1}{3}x-\frac{145}{27} \\ &= \left( x+\frac{4}{3}\right)^3-\frac{1}{3}x-\frac{145}{27} \end{split} $$
We would now like to set a new variable $y=\left(x+\frac{4}{3}\right)$ so that the equation ends up looking like $y^3+ay+b$ for some $a,b\in\mathbb{R}$. So we write the equation as:
$$ \left(x+\frac{4}{3}\right)^3-\frac{1}{3}\left(x+\frac{4}{3}\right)-\frac{133}{27}=y^3-\frac{1}{3}y-\frac{133}{27} $$
Now we need to use a trick due to Cardano. We set $y=u+v$ in our equation above and we get:
$$ \begin{split} (u+v)^3-\frac{1}{3}(u+v)-\frac{133}{27}&=u^3+3u^2v+3uv^2+v^3-\frac{1}{3}(u+v)-\frac{133}{27} \\&= u^3+v^3+3uv(u+v)-\frac{1}{3}(u+v)-\frac{133}{27}\\ &=u^3+v^3+(u+v)\left(3uv-\frac{1}{3}\right)-\frac{133}{27} \end{split} $$
and now here is the point of making $y=u+v$: we have some extra freedom to choose our $u$ and $v$ and a convenient choice for us is to make $3uv-\frac{1}{3}=0$ so that the middle term cancels and we get:
$$ u^3+v^3=\frac{133}{27} $$
Now the quadratic:
$$ (z-u^3)(z-v^3)=z^2-(u^3+v^3)z+u^3v^3=z^2-\frac{133}{27}z+\left(\frac{1}{9}\right)^3 $$
has roots $u^3$ and $v^3$. So we can solve this quadratic and then the cube roots of the solutions will give us $u$ and $v$. We can then substitute these values in to get $y$ and finally $x$. This is a lot of work though! This process can be used to solve any cubic however.