在Python中的线性函数直线插补查找零
Find the zero of the linear function straight line interpolation in Python
''' root = linInterp(f,x1,x2).
Finds the zero of the linear function f(x) by straight
line interpolation based on x = x1 and x2.
'''
def linInterp(f,x1,x2):
f1 = f(x1)
f2 = f(x2)
return x2 - f2*(x2 - x1)/(f2 - f1)
