```python import numpy as np def lagrange_interpolation(x, y, x_new): n = len(x) y_new = 0 for i in range(n): L = 1 for j in range(n): if i != j: L *= (x_new - x[j]) / (x[i] - x[j]) y_new += y[i] * L return y_new # 示例数据 x = np.array([0, 1, 2, 3, 4]) y = np.array([1, 2, 1, 3, 4]) # 求缓和曲线方程 x_new = np.linspace(0, 4, 100) y_new = [lagrange_interpolation(x, y, xi) for xi in x_new] # 输出结果 print("缓和曲线方程:") for i in range(len(x_new)): print(f"{x_new[i]:.2f}: {y_new[i]:.2f}") ``` [2024-05-24 21:06:47 | AI写代码神器 | 280点数解答]