嵌套间隔以查找函数的最小值

The goal of the function nestie is to find a local min for a given initial point using nested interval method(iteratively split the interval of interest). The stopping criterion is the Lipschitz Constant K = 0.001. Below you can find my unsuccessful python implementation. I'm not so sure what went wrong.

def nestie(a,v,w,fun):
    """
    a: initial point
    v,w: step sizes
    """
    (a,b,c) = (a,a+v,a+v+w)
    # 1st make sure the range includes a minimum
    if fun(b)>=fun(a) and fun(b)>=fun(c):
        if fun(b)>=fun(a) and fun(b)<=fun(c):
            if fun(b)<=fun(a) and fun(b)>=fun(c):
                i = 1
                while fun(a)>fun(b)<fun(c) ==0:
                    (a,b,c) = (a,a+i*v,a+i*v+i*w)
                    i += 1
    while abs(fun(c+0.0001)-fun(c))/0.0001 >=0.001:
        d = (b+c)/2
        e = (a+b)/2
        if fun(a)>fun(d)<fun(b) is True:
            d = b
            b = c
        if fun(b)>fun(e)<fun(c) is True:
            e = b
            b = a

    return c