<p>Using Newton-Raphson is an act of desperation. You are much better off finding the continued fraction that represents your function and calculating that. A CF will converge much faster and will produce the real root(s). Also, because the CF produces a ratio of two integers you have tight control over numeric precision and don't have to worry about accumulation of rounding errors and other similar hair-pulling-out problems.</p>

<p>To find the real roots of any polynomial function refer to "A Continued Fraction Algorithm for Approximating All Real Polynomial Roots" by David Rosen (1978).</p>

<p>------------ ADDENDUM 1 --- 11 OCT-----------------</p>

<p>Ok, you are solving a sextic. You have several options. The simplest is to use a Taylor approximation (say to the 3rd degree) in conjunction with Halley's method. This is much superior to Newton because it has cubic convergence and you can detect imaginary solutions. The disadvantage is that you will have rounding problems which may result in an incorrect answer.</p>

<p>The ideal option is to find the continued fraction that represents the monic root, because this CF will be computable as an integer ratio of any desired precision, thus elminating the problem of rounding. </p>

<p>One approach to computing this CF is via the Jacobi-Perron algorithm. See the paper Hendy and Jeans: <a href="http://www.ams.org/mcom/1981-36-154/S0025-5718-1981-0606514-X/S0025-5718-1981-0606514-X.pdf" rel="nofollow">http://www.ams.org/mcom/1981-36-154/S0025-5718-1981-0606514-X/S0025-5718-1981-0606514-X.pdf</a>. This paper shows the exact algorithm for computing cubic and quartic roots via CF approximation.</p>

<p>Note that if the sextic is reducible then it can converted into a quartic and quadratic: <a href="http://elib.mi.sanu.ac.rs/files/journals/tm/21/tm1124.pdf" rel="nofollow">http://elib.mi.sanu.ac.rs/files/journals/tm/21/tm1124.pdf</a>. The quartic is then solvable by the algorithm in the Hendy paper.</p>

<p>The general solution to generate a CF for a sextic can be done via the Rogers-Ramunajan CF. See the following paper for the method: <a href="http://arxiv.org/pdf/1111.6023v2" rel="nofollow">http://arxiv.org/pdf/1111.6023v2</a>. This will generate the CF for any sextic.</p>
Bracketing algorithm when root finding. Single root in "quadratic" function
<p>I am trying to implement a root finding algorithm. I am using the hybrid Newton-Raphson algorithm found in numerical recipes that works pretty nicely. But I have a problem in bracketing the root.</p>
<p>While implementing the root finding algorithm I realised that in several cases my functions have 1 real root and all the other imaginary (several of them, usually 6 or 9). The only root I am interested is in the real one so the problem is not there. The thing is that the function approaches the root like a cubic function, touching with the point the y=0 axis...</p>
<p>Newton-Rapson method needs some brackets of different sign and all the bracketing methods I found don't work for this specific case.</p>
<p>What can I do? It is pretty important to find that root in my program...</p>
<p>EDIT: more problems: sometimes due to reaaaaaally small numerical errors, say a variation of <code>1e-6</code> in some value the &quot;cubic&quot; function does NOT have that real root, it is just imaginary with a neglectable imaginary part... (checked with matlab)</p>
<p><strong>EDIT 2:</strong> Much more information about the problem.</p>
<p>Ok, I need root finding algorithm.</p>
<p>Info I have:</p>
<ul>
<li>The root I need to find is between [0-1] , if there are more roots outside that part I am not interested in them.</li>
<li>The root is real, there may be imaginary roots, but I don't want them.</li>
<li>Probably all the rest of the roots will be imaginary</li>
<li>The root may be double in that point, but I think that actually doesn't mater in numerical analysis problems</li>
<li>I need to use the root finding algorithm several times during the overall calculations, but the function will always be a polynomial</li>
<li>In one of the particular cases of the root finding, my polynomial will be similar to a quadratic function that touches Y=0 with the point. Example of a real case:
<img src="https://i.stack.imgur.com/kLu9I.jpg" alt="enter image description here" /></li>
<li>The coefficient may not be 100% precise and that really slight imprecision may make the function not to touch the Y=0 axis.</li>
<li>I cannot solve for this specific case because in other cases it may be that the  polynomial is pretty normal and doesn't make any &quot;strange&quot; thing.</li>
<li>The method I am actually using is NewtonRaphson hybrid, where if the derivative is really small it makes a bisection instead of NewRaph (found in <em>numerical recipes</em>).</li>
</ul>
<p>Matlab's answer to the function on the image:
roots:</p>
<pre><code>0.853553390593276 + 0.353553390593278i
0.853553390593276 - 0.353553390593278i
0.146446609406726 + 0.353553390593273i
0.146446609406726 - 0.353553390593273i
0.499999999999996 + 0.000000040142134i
0.499999999999996 - 0.000000040142134i
</code></pre>
<p>The function is a real example I prepared where I know that the answer I want is <code>0.5</code></p>
<p>Note:
I still haven't check completely some of the answers I you people have give me (Thank you!), I am just trying to give al the information I already have to complete the question.</p>