资源描述:
《实验题目1 lagrange插值》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验题目1Lagrange插值摘要给定平面上n+1个不同的数据点:则满足条件的n次拉格朗日插值多项式是存在唯一的。若,且充分光滑,则当时,有误差估计式前言利用拉格朗日插值多项式求的近似值程序设计流程拉格朗日插值框图开始结束输入(xi,yi),ni=0,1,2,…,nL=0i=0xl=1xl=*xlj=0,1,…,i-1,i+1,…,nL=L+xl*i=n?输出y否是i=i+1问题1(1)N=5时,程序运行如下:TestLag(inline('1./(1+x.^2)'),-5,5,5,0.75:4.75);将区间[-5,5]分为了5段计算插值的点xi=0.75
2、001.75002.75003.75004.7500计算出的插值yi=0.90540.52580.0096-0.3568-0.1595插值点处函数值yFact=0.64000.24620.11680.06640.0424计算误差err=-0.2654-0.27960.10720.42320.2020N=10时,程序运行如下:TestLag(inline('1./(1+x.^2)'),-5,5,10,0.75:4.75);将区间[-5,5]分为了10段计算插值的点xi=0.75001.75002.75003.75004.7500计算出的插值yi=0.69070
3、.23300.11220.1084-0.2360插值点处函数值yFact=0.64000.24620.11680.06640.0424计算误差err=-0.05070.01320.0045-0.04200.2785N=20时,程序运行如下:TestLag(inline('1./(1+x.^2)'),-5,5,20,0.75:4.75);将区间[-5,5]分为了20段计算插值的点xi=0.75001.75002.75003.75004.7500计算出的插值yi=0.64130.24910.12820.19036.4150插值点处函数值yFact=0.64000
4、.24620.11680.06640.0424计算误差err=-0.0013-0.0029-0.0114-0.1239-6.3726问题1(2)N=5时,程序运行如下:TestLag(inline('exp(x)'),-1,1,5,[-0.95-0.050.050.95]);将区间[-1,1]分为了5段计算插值的点xi=-0.9500-0.05000.05000.9500计算出的插值yi=0.38630.95131.05122.5863插值点处函数值yFact=0.38670.95121.05132.5857计算误差err=1.0e-003*0.4471-0
5、.10510.1069-0.6129N=10时,程序运行如下:TestLag(inline('exp(x)'),-1,1,10,[-0.95-0.050.050.95]);将区间[-1,1]分为了10段计算插值的点xi=-0.9500-0.05000.05000.9500计算出的插值yi=0.38670.95121.05132.5857插值点处函数值yFact=0.38670.95121.05132.5857计算误差err=1.0e-008*-0.3126-0.0055-0.0055-0.3714N=20时,程序运行如下:TestLag(inline('ex
6、p(x)'),-1,1,20,[-0.95-0.050.050.95]);将区间[-1,1]分为了20段计算插值的点xi=-0.9500-0.05000.05000.9500计算出的插值yi=0.38670.95121.05132.5857插值点处函数值yFact=0.38670.95121.05132.5857计算误差err=1.0e-012*0.73390-0.0002-0.5671问题2(1)N=5时,程序运行如下:TestLag(inline('1./(1+x.^2)'),-1,1,5,[-0.95-0.050.050.95]);将区间[-1,1]分
7、为了5段计算插值的点xi=-0.9500-0.05000.05000.9500计算出的插值yi=0.51360.99780.99780.5136插值点处函数值yFact=0.52560.99750.99750.5256计算误差err=0.0121-0.0002-0.00020.0121N=10时,程序运行如下:TestLag(inline('1./(1+x.^2)'),-1,1,10,[-0.95-0.050.050.95]);将区间[-1,1]分为了10段计算插值的点xi=-0.9500-0.05000.05000.9500计算出的插值yi=0.52430
8、.99750.99750.5243插值点处函数值yF