文正学院数值逼近 实验二.docx
- 文档编号:29041767
- 上传时间:2023-07-20
- 格式:DOCX
- 页数:10
- 大小:38.51KB
文正学院数值逼近 实验二.docx
《文正学院数值逼近 实验二.docx》由会员分享,可在线阅读,更多相关《文正学院数值逼近 实验二.docx(10页珍藏版)》请在冰豆网上搜索。
文正学院数值逼近实验二
2011学年第一学期
《数值逼近》上机实验报告
院系:
文正学院专业:
信息与计算科学
姓名:
许志杰学号:
0917417001
年级:
2009
实验场地及名称:
文正学院机房
实验时间:
10月17日
实验成绩:
指导教师:
陈旻昕
上机实验二
已知函数y=ex,写出它在结点组-1,-1/2,0,1/2,1上的四次lagrange插值多项式。
解:
代码:
在untitled1中:
clear
closeall
x=-1:
0.1:
1
y=exp(x);
plot(x,y)
%四阶
xi=[-1,-0.3,0,0.3,1];
yi=exp(xi);
xx=-1:
0.1:
1;
yy=lagrange(xi,yi,xx);
holdon
plot(xx,yy,'-r')
在f中:
functiony=f(x)
y=exp(x)
在lagrange中:
functionyy=lagrange(xi,yi,xx)
yy=0
fork=1:
length(xi)
s=1;
fori1=1:
length(xi)
if(i1~=k)
s=s.*(xx-xi(i1))./(xi(k)-xi(i1))
end
end
yy=yy+yi(k)*s;
end
运行结果图片:
运行数据:
x=
Columns1through8
-1.0000-0.9000-0.8000-0.7000-0.6000-0.5000-0.4000-0.3000
Columns9through16
-0.2000-0.100000.10000.20000.30000.40000.5000
Columns17through21
0.60000.70000.80000.90001.0000
yy=
0
s=
Columns1through8
1.00000.80000.60000.40000.20000-0.2000-0.4000
Columns9through16
-0.6000-0.8000-1.0000-1.2000-1.4000-1.6000-1.8000-2.0000
Columns17through21
-2.2000-2.4000-2.6000-2.8000-3.0000
s=
Columns1through8
1.00000.72000.48000.28000.12000-0.0800-0.1200
Columns9through16
-0.1200-0.080000.12000.28000.48000.72001.0000
Columns17through21
1.32001.68002.08002.52003.0000
s=
Columns1through8
1.00000.67200.41600.22400.08800-0.0480-0.0640
Columns9through16
-0.0560-0.032000.03200.05600.06400.04800
Columns17through21
-0.0880-0.2240-0.4160-0.6720-1.0000
s=
Columns1through8
1.00000.63840.37440.19040.07040-0.0336-0.0416
Columns9through16
-0.0336-0.017600.01440.02240.02240.01440
Columns17through21
-0.0176-0.0336-0.0416-0.03360
s=
Columns1through8
00.20000.40000.60000.80001.00001.20001.4000
Columns9through16
1.60001.80002.00002.20002.40002.60002.80003.0000
Columns17through21
3.20003.40003.60003.80004.0000
s=
Columns1through8
00.36000.64000.84000.96001.00000.96000.8400
Columns9through16
0.64000.36000-0.4400-0.9600-1.5600-2.2400-3.0000
Columns17through21
-3.8400-4.7600-5.7600-6.8400-8.0000
s=
Columns1through8
00.50400.83201.00801.05601.00000.86400.6720
Columns9through16
0.44800.21600-0.1760-0.2880-0.3120-0.22400
Columns17through21
0.38400.95201.72802.73604.0000
s=
Columns1through8
00.63840.99841.14241.12641.00000.80640.5824
Columns9through16
0.35840.15840-0.1056-0.1536-0.1456-0.08960
Columns17through21
0.10240.19040.23040.18240
s=
Columns1through8
00.10000.20000.30000.40000.50000.60000.7000
Columns9through16
0.80000.90001.00001.10001.20001.30001.40001.5000
Columns17through21
1.60001.70001.80001.90002.0000
s=
Columns1through8
0-0.0800-0.1200-0.1200-0.080000.12000.2800
Columns9through16
0.48000.72001.00001.32001.68002.08002.52003.0000
Columns17through21
3.52004.08004.68005.32006.0000
s=
Columns1through8
0-0.2240-0.3120-0.2880-0.176000.21600.4480
Columns9through16
0.67200.86401.00001.05601.00800.83200.50400
Columns17through21
-0.7040-1.6320-2.8080-4.2560-6.0000
s=
Columns1through8
0-0.4256-0.5616-0.4896-0.281600.30240.5824
Columns9through16
0.80640.95041.00000.95040.80640.58240.30240
Columns17through21
-0.2816-0.4896-0.5616-0.42560
s=
Columns1through8
00.06670.13330.20000.26670.33330.40000.4667
Columns9through16
0.53330.60000.66670.73330.80000.86670.93331.0000
Columns17through21
1.06671.13331.20001.26671.3333
s=
Columns1through8
0-0.0267-0.0400-0.0400-0.026700.04000.0933
Columns9through16
0.16000.24000.33330.44000.56000.69330.84001.0000
Columns17through21
1.17331.36001.56001.77332.0000
s=
Columns1through8
00.04800.06400.05600.03200-0.0320-0.0560
Columns9through16
-0.0640-0.048000.08800.22400.41600.67201.0000
Columns17through21
1.40801.90402.49603.19204.0000
s=
Columns1through8
00.18240.23040.19040.10240-0.0896-0.1456
Columns9through16
-0.1536-0.105600.15840.35840.58240.80641.0000
Columns17through21
1.12641.14240.99840.63840
s=
Columns1through8
00.05000.10000.15000.20000.25000.30000.3500
Columns9through16
0.40000.45000.50000.55000.60000.65000.70000.7500
Columns17through21
0.80000.85000.90000.95001.0000
s=
Columns1through8
0-0.0133-0.0200-0.0200-0.013300.02000.0467
Columns9through16
0.08000.12000.16670.22000.28000.34670.42000.5000
Columns17through21
0.58670.68000.78000.88671.0000
s=
Columns1through8
00.01200.01600.01400.00800-0.0080-0.0140
Columns9through16
-0.0160-0.012000.02200.05600.10400.16800.2500
Columns17through21
0.35200.47600.62400.79801.0000
s=
Columns1through8
0-0.0336-0.0416-0.0336-0.017600.01440.0224
Columns9through16
0.02240.01440-0.0176-0.0336-0.0416-0.03360
Columns17through21
0.07040.19040.37440.63841.0000
X=
Y=
总结:
结点取得越多,ex函数的误差越小。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 文正学院数值逼近 实验二 学院 数值 逼近 实验