= 0) { throw new \Exception("Function values at endpoints must have opposite signs."); } $iteration = 0; while (($b - $a) / 2 > self::EPSILON && $iteration < $maxIterations) { $c = ($a + $b) / 2; $y = $func($c); if ($y === 0.0) { return $c; } if ($y * $func($a) < 0) { $b = $c; } else { $a = $c; } ++$iteration; } return ($a + $b) / 2; } }