from typing import Callable def bisect( f: Callable[ [ float ], float ], x_1: float, x_2: float, prec: float ) -> float: mid = ( x_1 + x_2 ) / 2 if abs( x_1 - x_2 ) < 2 * prec: return mid if f( mid ) * f( x_1 ) <= 0: return bisect( f, x_1, mid, prec ) else: return bisect( f, mid, x_2, prec ) import run_tests