77 #define CMD "Optimist::ScalarRootFinder::Halley::solve(...): "
87 Real residuals, step_norm;
88 Real x_old, x_new, function_old, function_new, step_old, step_new;
89 Real first_derivative_old, second_derivative_old;
108 if (std::abs(first_derivative_old) < EPSILON_LOW) {
110 first_derivative_old = (first_derivative_old > 0.0) ? EPSILON_LOW : -EPSILON_LOW;
112 if (std::abs(second_derivative_old) < EPSILON_LOW) {
114 second_derivative_old = (second_derivative_old > 0.0) ? EPSILON_LOW : -EPSILON_LOW;
116 step_old = -(function_old / first_derivative_old) * (1.0 - (function_old * second_derivative_old) /
117 (first_derivative_old * first_derivative_old));
121 residuals = std::abs(function_old);
122 step_norm = std::abs(step_old);
124 if (residuals < tolerance_residuals || step_norm < tolerance_step_norm) {
131 damped = this->
damp(function, x_old, function_old, step_old, x_new, function_new, step_new);
135 x_new = x_old + step_old;
141 function_old = function_new;