import math

def bisection_solve(x1, x2, eps):
    fx1, fx2 = f(x1), f(x2)
    while x2-x1 >= eps:    # Invariant: x2 >= x1
        m = (x1+x2) / 2.0
        fm = f(m)
        if (fx1 >= 0 and fm >= 0) or (fx1 <= 0 and fm <= 0):
            x1, fx1 = m, fm
        else:
            x2, fx2 = m, fm
    return (x1+x2) / 2.0

def f(x):
    return x**3-3*math.sin(x)+1
