数值分析-Lagrange插值
计算Lagrange插值多项式在x=x0处的值
实验方法与步骤
- function[y0,N]=Lagrange_eval(X,Y,x0)
- 利用Lagrange插值多项式
X=[0.5,0.6];Y=[-0.693147,-0.510826];x0=0.54;
用线性插值求出ln0.54的近似值 - X=[0.4,0.5,0.6];Y=[-0.916291,-0.693147,-0.510826];x0=0.54;
用二次插值求出ln0.54的近似值 - X=[0.4,0.5,0.6,0.7];Y=[-0.916291,-0.693147,-0.510826,-0.356675];x0=0.54;
用三次插值求出ln0.54的近似值
代码:
function[y0,N]=Lagrange_eval(X,Y,x0)
%X,Y是已知的插值点坐标点
%x0是插值点
%y0