diff --git a/main.cpp b/main.cpp index 1c28f41..125f0d9 100644 --- a/main.cpp +++ b/main.cpp @@ -70,22 +70,22 @@ double chordMethod(double left, double right, double error, double (*f)(double x double chordMethod2(double left, double right, double error, double (*f)(double)) { - double c; + double center; - while(std::fabs( f(right) - f(left) ) > error) + while(std::fabs(right - left) > error) { - c = ( f(right) * left - f(left) * right) / ( f(right) - f(left) ); + center = ( f(right) * left - f(left) * right) / ( f(right) - f(left) ); - if( f(left) * f(c) > 0) + if( f(left) * f(center) < 0) { - left = c; + right = center; } else { - right = c; + left = center; } } - return c; + return center; } int main()