1.下表是水的表面张力对温度的函数数据: T(℃) 0 20 40 60 80 σ×103(N/m) 78.2… · The Chat Archivegpt-3.5-turbo-0301· openai
Suzhen/CodeChat 1.下表是水的表面张力对温度的函数数据: T(℃) 0 20 40 60 80 σ×103(N/m) 78.2 73.4 70.2 66.7 63.2…
Download ▾
1.下表是水的表面张力对温度的函数数据:
T(℃) 0 20 40 60 80
σ×103(N/m) 78.2 73.4 70.2 66.7 63.2
利用牛顿插值法求出穿过上述数据点的多项式(结果输出多项式),画出σ相对于T的关系图,并标出数据点的位置。
给出python代码,将最后图片保存在 D:\网页下载(图片中σ范围为0-100)
Assistant
根据牛顿插值法可得多项式为:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
P(x)=f(x0)+f[x0,x1](x−x0)+f[x0,x1,x2](x−x0)(x−x1)+f[x0,x1,x2,x3](xx0)(x−x1)(x−x2)+f[x0,x1,x2,x3,xx0)(x−x1)(x−x2)(x−x3)
其中,x0=0,x1=20,x2=40,x3=60,x4=80,f(x)为给定的表面张力函数。
| x | f(x) |
|---|
| 0 | 78.2 |
| 20 | 73.4 |
| 40 | 70.2 |
| 60 | 66.7 |
| 80 | 63.2 |
P(x)=78.2−0.24x+0.0004x(x−20)−0.000025x(x−20)(x−40)+1.25×10−7x(x−20)(x−40)(x−60) import numpy as np
from matplotlib import pyplot as plt
T = [0, 20, 40, 60, 80]
sigma = [78.2, 73.4, 70.2, 66.7, 63.2]
x = np.linspace(0, 80, 100)
P = 78.2 - 0.24*x + 0.0004*x*(x-20) - 0.000025*x*(x-20)*(x-40) + 1.25e-7*x*(x-20)*(x-40)*(x-60)
plt.plot(x, P, label='插值函数')
plt.scatter(T, sigma, label='数据点')
plt.ylim(0, 100)
plt.xlabel('T(℃)')
plt.ylabel('σ×103(N/m)')
plt.legend()
plt.savefig('D:\\网页下载\\sigma.png')
plt.show()
−
4
]
(
x
−