def bisection1D(f, a, b, delta=0.00001):
    """
    Find solution to f(x) = 0 with bisection method
    :param f: function f
    :param a: left starting point for x
    :param b: right starting point for x
    :param delta: threshold for solution
    :return: x
    """
    start, end = a, b
    if f(a) == 0:
        return a
    elif f(b) == 0:
        return b
    elif f(a) * f(b) > 0:
        print("couldn't find root in [{}, {}], return {}".format(a, b, None))
        return None
    else:
        mid = (start + end) / 2
        while abs(start - mid) > delta:
            if f(mid) == 0:
                return mid
            elif f(mid) * f(start) < 0:
                end = mid
            else:
                start = mid
            mid = (start + end) / 2
        return mid