In [ ]:
def bisect(f, a, b):
    cs = [a,b]
    while True:
        c = (a + b) / 2
        cs.append(c)
        if abs(f(c)) < 1e-6:
            return cs
        if f(a) * f(c) < 0:
            b = c
        else:
            a = c
    return cs