在python中使用割线法求复方程的根

在python中使用割线法求复方程的根,python,Python,我的代码: 输入数学 z = float(input("Enter 'es(T)' value : ")) def f(x) : y=z-611*math.exp(5417*((1/273)-(1/x))) return y def delta(x1,x2): y=x2-x1 return y def m_sec(x1,x2): y=(f(x2)-f(x1))/delta(x1,x2) return y def sec_met

我的代码: 输入数学

z = float(input("Enter 'es(T)' value : "))

def f(x) :    
    y=z-611*math.exp(5417*((1/273)-(1/x)))
    return y

def delta(x1,x2):

    y=x2-x1
    return y

def m_sec(x1,x2):

    y=(f(x2)-f(x1))/delta(x1,x2)
    return y 

def sec_method(x1,x2):

    while True :
        try :
            x3= x2 -(f(x2)/(m_sec(x1,x2)))
            return x3
        except ZeroDivisionError:
            break

first = float(input("Enter 'first' value : "))

second = float(input("Enter 'second' value : "))

for i in range(0,30):
    temp = sec_method(first,second)

    if z-f(first)!=0 :
        print (first, second, temp)
        first = second
        second =temp

    else :
        print ("The end!")
        break
当我使用这段代码时,结果只显示数字越来越小。 我想做的是找到根“x”,它满足方程z-f(x)==0

我怎样才能解决这个问题