|
|
|
@ -0,0 +1,27 @@
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
# 给定数据
|
|
|
|
|
t_values = np.array([0, 10, 15, 20, 22.5, 30])
|
|
|
|
|
v_values = np.array([0, 227.04, 362.78, 517.35, 602.97, 901.67])
|
|
|
|
|
|
|
|
|
|
# 确定插值区间,选择包含 t=16 的四个数据点
|
|
|
|
|
t0 = t_values[1] # 10
|
|
|
|
|
t1 = t_values[2] # 15
|
|
|
|
|
t2 = t_values[3] # 20
|
|
|
|
|
t3 = t_values[4] # 22.5
|
|
|
|
|
|
|
|
|
|
v0 = v_values[1] # 227.04
|
|
|
|
|
v1 = v_values[2] # 362.78
|
|
|
|
|
v2 = v_values[3] # 517.35
|
|
|
|
|
v3 = v_values[4] # 602.97
|
|
|
|
|
|
|
|
|
|
# 构造Lagrange插值多项式
|
|
|
|
|
p = v0 * ((16 - t1) * (16 - t2) * (16 - t3)) / ((t0 - t1) * (t0 - t2) * (t0 - t3)) + \
|
|
|
|
|
v1 * ((16 - t0) * (16 - t2) * (16 - t3)) / ((t1 - t0) * (t1 - t2) * (t1 - t3)) + \
|
|
|
|
|
v2 * ((16 - t0) * (16 - t1) * (16 - t3)) / ((t2 - t0) * (t2 - t1) * (t2 - t3)) + \
|
|
|
|
|
v3 * ((16 - t0) * (16 - t1) * (16 - t2)) / ((t3 - t0) * (t3 - t1) * (t3 - t2))
|
|
|
|
|
|
|
|
|
|
# 计算 t=16 时的速度
|
|
|
|
|
velocity_at_16 = p
|
|
|
|
|
|
|
|
|
|
print(f"使用Lagrange插值法,t=16 秒时的速度为: {velocity_at_16:.2f} m/s")
|