def METHOD_NAME(fun, a, b, tol=1e-5):
    phi0 = (np.sqrt(5) - 1)/2
    phi1 = (3 - np.sqrt(5))/2
    a, b = min(a, b), max(a, b)
    h = b - a
    if h <= tol:
        return (a+b)/2
    n = int(np.ceil(np.log(tol/h)/np.log(phi0)))
    c = a + phi1*h
    d = a + phi0*h
    yc = fun(c)
    yd = fun(d)
    for k in range(n):
        if yc < yd:
            b = d
            d = c
            yd = yc
            h = phi0*h
            c = a + phi1*h
            yc = fun(c)
            print("yc:%12.11g"%(yc))
        else:
            a = c
            c = d
            yc = yd
            h = phi0*h
            d = a + phi0*h
            yd = fun(d)
            print("yd:%12.11g"%(yd))
    if yc < yd:
        return (a+d)/2
    else:
        return (c+b)/2