计算方法实验报告Word文档格式.docx
《计算方法实验报告Word文档格式.docx》由会员分享,可在线阅读,更多相关《计算方法实验报告Word文档格式.docx(16页珍藏版)》请在冰豆网上搜索。
注:
(可以用C语言或者matlab语言)
2.实验设备
matlab
3.实验容及步骤
解方程f(x)=x5-3x3-2x2+2=0
4.实验结果及分析
二分法:
数据:
f=x^5-3*x^3-2*x^2+2
[nxaxbxcfc]
1-3302
2.0000-3.00000-1.50000.0313
3.0000-3.0000-1.5000-2.2500-31.6182
4.0000-2.2500-1.5000-1.8750-8.4301
5.0000-1.8750-1.5000-1.6875-2.9632
6.0000-1.6875-1.5000-1.5938-1.2181
7.0000-1.5938-1.5000-1.5469-0.5382
8.0000-1.5469-1.5000-1.5234-0.2405
9.0000-1.5234-1.5000-1.5117-0.1015
10.0000-1.5117-1.5000-1.5059-0.0343
11.0000-1.5059-1.5000-1.5029-0.0014
12.0000-1.5029-1.5000-1.50150.0150
13.0000-1.5029-1.5015-1.50220.0068
14.0000-1.5029-1.5022-1.50260.0027
15.0000-1.5029-1.5026-1.50270.0007
16.0000-1.5029-1.5027-1.5028-0.0003
17.0000-1.5028-1.5027-1.50280.0002
18.0000-1.5028-1.5028-1.5028-0.0001
19.0000-1.5028-1.5028-1.50280.0001
20.0000-1.5028-1.5028-1.5028-0.0000
牛顿迭代法
>
symsx;
f=(x^5-3*x^3-2*x^2+2)
[x,k]=Newtondd(f,0,1e-12)
f=x^5-3*x^3-2*x^2+2
x=NaN
k=2
实验二:
解线性方程组的迭代法
1.掌握雅克比迭代法和高斯-塞德尔迭代法的原理
2.根据实验容编写雅克比迭代法和高斯-塞德尔迭代法的算法实现
Matlab
1、分别用雅克比迭代法和高斯-塞德尔迭代法解方程Ax=b
其中A=[4-10-100
-14-10-10
0-14-10-1
-10-14-10
0-10-14-1
00-10-14]
b=[0;
5;
-2;
6]
(雅克比迭代法)
a=[4-10-100;
-14-10-10;
0-14-10-1;
-10-14-10;
0-10-14-1;
00-10-14]
b=[0;
6]
x=agui_jacobi(a,b)
a=4-10-100
00-10-14
b=05-25-26
k=1
01.2500-0.50001.2500-0.50001.5000
k=2
0.62501.00000.50001.00000.50001.2500
k=3
0.50001.65630.31251.65630.31251.7500
k=4
0.82811.53130.76561.53130.76561.6563
k=5
0.76561.83980.67971.83980.67971.8828
k=6
0.91991.78130.89061.78130.89061.8398
k=7
0.89061.92530.85061.92530.85061.9453
k=8
0.96261.89790.94901.89790.94901.9253
k=9
0.94901.96510.93031.96510.93031.9745
k=10
0.98261.95240.97621.95240.97621.9651
k=11
0.97621.98370.96751.98370.96751.9881
k=12
0.99191.97780.98891.97780.98891.9837
k=13
0.98891.99240.98481.99240.98481.9944
k=14
0.99621.98960.99481.98960.99481.9924
k=15
0.99481.99650.99291.99650.99291.9974
k=16
0.99821.99520.99761.99520.99761.9965
k=17
0.99761.99830.99671.99830.99671.9988
k=18
0.99921.99770.99891.99770.99891.9983
k=19
0.99891.99920.99851.99920.99851.9994
k=20
0.99961.99890.99951.99890.99951.9992
k=21
0.99951.99960.99931.99960.99931.9997
k=22
0.99981.99950.99981.99950.99981.9996
k=23
0.99981.99980.99971.99980.99971.9999
k=24
0.99991.99980.99991.99980.99991.9998
k=25
0.99991.99990.99981.99990.99981.9999
k=26
1.00001.99990.99991.99990.99991.9999
k=27
0.99992.00000.99992.00000.99992.0000
x=0.99992.00000.99992.00000.99992.0000
(高斯-赛德尔迭代法迭代法)
x=agui_GS(a,b)
Columns1through5
01.0000-0.00001.00000.0000
Column6
1.0000
0.00001.00000.50001.37500.8438
1.5859
k=3
0.34381.67190.40821.64890.7267
1.2837
0.33021.11630.26221.82980.5574
1.4549
0.73651.88910.54341.95940.0758
1.6548
k=6
0.96211.39530.25241.32260.3432
1.6489
0.67951.31880.07261.77380.9354
1.5020
0.02311.25780.38341.83550.8988
1.3206
0.02331.82640.74561.41690.3910
1.7842
k=10
0.31081.36190.39071.02310.0423
1.1083
0.34631.69480.20661.64880.8630
1.5174
0.83591.47640.91061.90240.7240
1.1587
0.84471.86980.73271.32540.3385
1.5178
k=14
0.29881.34250.04641.92090.4453
1.8729
x=0.2988
1.3425
0.0464
1.9209
0.4453
实验三:
插值与拟合
1、掌握线性插值、抛物线插值、拉格朗日插值,三次样条插值与拟合
2、根据实验容,编写三次样条插值(一阶导数)的算法实现。
3、根据实验容,编写最小二乘法的算法实现。
(1)、给定的插值条件如下:
i
1
2
3
4
5
6
7
Xi
8