def root(f, L, U, EPS=10**-10, TOL=100): """ Given a real valued continuous function f and L 0 U = M # continue search in lower half print("No root found in", TOL, "iterations") return None def sq(x): return x**2-4 import math def sin(x): return math.sin(10**6*x) """ Successful run """ #print(root(lambda x:x**2-4, 0.0, 3.0)) """ Not enough tolerance example """ #print(root(lambda x:x**2-4, 0.0, 3.0, TOL=10)) """ Interval too small. Takes 53 iterations. A case where L