>>But you can use a more complicated algebraic equation to generate x_1, x_3, x_5, .... x_n.
That's an idea, I suppose - perhaps it would also reduce the chance of overshooting into the 'zone' of a different root.
>>Adding a random factor somewhere would make Newton's method always converge, I think.
I was under the impression that it would always converge anyway unless you picked a spot on a vertical asymptote or extremum or something? Anyway, I don't want to spend much more time on this - it was more of a 'prove I can do it' thing, really
**EDIT**
OK, final version of findRootNewton() - I'm going to leave it at this; if anyone wants to improve on it, go ahead, but I'm done with it for now (until I can actually figure out what I'm doing )
Code:
double findRootNewton(const Polynomial& p, const Polynomial& dp, double x1, double x2)
{
Polynomial ddp = dp.derivative();
double x = (x1 + x2) / 2;
double xNext;
double evalF, evalDF, evalDDF;
for(unsigned long its = 0; its < 700; ++its)
{
evalF = p.evaluate(x);
evalDF = dp.evaluate(x);
evalDDF = ddp.evaluate(x);
xNext = x - (evalF/evalDF * (1 + ((evalF * evalDDF) / (2 * evalDF * evalDF))));
if(equals(x, xNext, 2))
return xNext;
x = xNext;
}
return x;
}