数值分析与算法设计--拉格朗日线性插值
拉格朗日线性插值
公式
当只有两个数据点 $(x_0, y_0)$ 和 $(x_1, y_1)$ 时,拉格朗日插值多项式为一次多项式(直线):
$$
P_1(x) = y_0 \cdot \frac{x - x_1}{x_0 - x_1} + y_1 \cdot \frac{x - x_0}{x_1 - x_0}
$$
这等价于两点式直线方程。
题目
已知:
- $x_0 = 100,\ y_0 = \sqrt{100} = 10$
- $x_1 = 121,\ y_1 = \sqrt{121} = 11$
- 要求:$x = 115$ 时的 $y \approx P_1(115)$
解答
点击查看答案
代入公式:$$
P_1(115) = 10 \cdot \frac{115 - 121}{100 - 121} + 11 \cdot \frac{115 - 100}{121 - 100}
$$
计算各部分:
- $115 - 121 = -6$
- $100 - 121 = -21$
- $115 - 100 = 15$
- $121 - 100 = 21$
所以:
$$
P_1(115) = 10 \cdot \frac{-6}{-21} + 11 \cdot \frac{15}{21}
= 10 \cdot \frac{6}{21} + 11 \cdot \frac{15}{21}
$$
化简分数:
- $\frac{6}{21} = \frac{2}{7}$
- $\frac{15}{21} = \frac{5}{7}$
因此:
$$
P_1(115) = 10 \cdot \frac{2}{7} + 11 \cdot \frac{5}{7}
= \frac{20}{7} + \frac{55}{7}
= \frac{75}{7}
\approx 10.7142857
$$
与真实值比较
真实值:
$$
\sqrt{115} \approx 10.7238053
$$
插值结果:
$$
P_1(115) \approx 10.7143
$$
误差 ≈ $10.7238 - 10.7143 = 0.0095$,相对误差约 0.09%,效果不错!
- Title: 数值分析与算法设计--拉格朗日线性插值
- Author: 姜智浩
- Created at : 2026-01-17 11:45:14
- Updated at : 2026-01-17 13:39:29
- Link: https://super-213.github.io/zhihaojiang.github.io/2026/01/17/20260117数值分析与算法设计--拉格朗日线性插值/
- License: This work is licensed under CC BY-NC-SA 4.0.