Dave,My 'n' is a redundant member data in a class Newton, so it is declared in .hpp file (BTW my code is always runnable!) and solve() is a member function in Newton.Sorry, I missed one line of your solution. The essential crux is: Quotedouble hn = 100.0;while ( fabs(hn = -myF(xPrevious) / derivative(xPrevious) ) > tol) So, I think your solution has almost exactly the same effec as goto. The check must be done immediately.BUT if the iteration converges at the first test, where is the xCurrent value? I think you must sayxCurrent = xPrevious, before the start of the while.otherwise you will get a run-time error (xCurrent defined but given no value!).yes?
Last edited by Cuchulainn
on February 4th, 2009, 11:00 pm, edited 1 time in total.