MathPHP\NumericalAnalysis\RootFinding\BisectionMethod::validate PHP Метод

validate() приватный статический Метод

If f($a) and f($b) have the same sign, we cannot use the intermediate value theorem to guarantee a root is between $a and $b. This exposes the risk of an endless loop, so we throw an Exception. If $a = $b, then clearly we cannot run our loop as $a and $b will themselves be the midpoint, so we throw an Exception.
private static validate ( callable $function, number $a, number $b, number $tol )
$function callable f(x) callback function
$a number The start of the interval which contains a root
$b number The end of the interval which contains a root
$tol number Tolerance; How close to the actual solution we would like.
    private static function validate(callable $function, $a, $b, $tol)
    {
        Validation::tolerance($tol);
        Validation::interval($a, $b);
        $f⟮a⟯ = $function($a);
        $f⟮b⟯ = $function($b);
        if (Special::sgn($f⟮a⟯) === Special::sgn($f⟮b⟯)) {
            throw new Exception\BadDataException('Input function has the same sign at the start and end of the interval. Choose start and end points such that the function evaluated at those points has a different sign (one positive, one negative).');
        }
    }
BisectionMethod