Alternative chord method

This commit is contained in:
2024-10-12 16:34:55 +03:00
parent 3f225e51e6
commit d4f41ea729

View File

@@ -68,6 +68,26 @@ double chordMethod(double left, double right, double error, double (*f)(double x
return right;
}
double chordMethod2(double left, double right, double error, double (*f)(double))
{
double c;
while(std::fabs( f(right) - f(left) ) > error)
{
c = ( f(right) * left - f(left) * right) / ( f(right) - f(left) );
if( f(left) * f(c) > 0)
{
left = c;
}
else {
right = c;
}
}
return c;
}
int main()
{
// Включим языковые настройки для корректного отображения русских символов