拉格朗日插值法
来源:互联网 发布:简历 协同过滤算法 编辑:程序博客网 时间:2024/05/17 06:12
python代码实现插值拟合 1/(1+25x^2)
import matplotlib.pyplot as pltimport numpy as npdef f(x): return 1/(1+x**2)def L(x, X, Y1): Ln = 0.0000 t = 0 for j in X: Molecule = 1.0000 Denominator = 1.0000 for i in X: if i != j: Molecule *= x-i Denominator *= j-i k = Molecule/Denominator Ln += Y1[t] * k t+=1 return LnX = np.arange(-5,5,0.5)X1 = np.arange(-5,5,0.1)Y = f(X)Y1 = f(X1)Y2 = L(X1, X, Y)print(Y1)print(Y2)fig = plt.figure(figsize=(8,8))ax = fig.add_subplot(111)ax.set_ylim(-5,5)ax.set_xlim(-5,5)ax.plot(X1, Y1)ax.plot(X1, Y2)plt.show()
图结果
两边的差距过大的现象成为龙格现象。解决方案是分段插值
0 0
- 拉格朗日插值法
- 拉格朗日插值法
- 拉格朗日插值法
- 拉格朗日插值法
- 拉格朗日插值法
- 拉格朗日插值法
- 拉格朗日插值法
- 拉格朗日插值法
- 拉格朗日插值法
- 拉格朗日插值法
- 拉格朗日插值法
- 拉格朗日插值法
- 拉格朗日插值法
- 拉格朗日插值法
- [拉格朗日插值法]拉格朗日插值法小结
- 拉格朗日插值法(Lagrange)
- 拉格朗日插值法实现
- matlab 拉格朗日插值法
- java执行bat文件
- Windows下编译X264,VS2015运行
- CC2640之广播MAC地址
- root、普通用户touch、mkdir文件、目录,初始权限详解
- matplotlib的基本用法(七)——绘制散点图
- 拉格朗日插值法
- python 3.0特点(更新中……)
- UVALive
- CDOJ 1324 卿学姐与公主 (分块or线段树)
- K NEAREST NEIGHBOR 算法
- 【京东商城首页实战5】给网页添加logo
- java面试知识点总结
- 低功耗蓝牙BLE之广播
- Node版本切换n