# 定义x、y散点坐标
import numpy as np
x = [1.414, 1.600, 1.700, 1.720, 1.732, 1.740, 1.750, 1.800, 1.875, 2.000]
y = [929.092, 930.713, 929.903, 930.713, 931.524, 927.472, 925.446, 927.066, 924.230, 928.282]
y= [yi-930.0 for yi in y]
# print(y)
z1 = np.polyfit(x, y, 7) # 用7次多项式拟合,可改变多项式阶数;
print(z1) #显示多项式系数
p1 = np.poly1d(z1) #得到多项式系数,按照阶数从高到低排列
# print(p1) #显示多项式
from functools import reduce
def polynomial(coefficient, x):
return reduce(lambda c1, c2: c1 * x + c2, coefficient)
res=polynomial(z1,1.720)
# res=polynomial([1,2,1],3)
# res=polynomial([10841.5747056069, -24457.2572571241, 22489.1422245109,-9130.76364970551,1380.67465252012], 1.732)
print("result")
print(res+930.0)