微分方程数值解欧拉法Word格式文档下载.docx
《微分方程数值解欧拉法Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《微分方程数值解欧拉法Word格式文档下载.docx(12页珍藏版)》请在冰豆网上搜索。
![微分方程数值解欧拉法Word格式文档下载.docx](https://file1.bdocx.com/fileroot1/2022-11/27/824aff63-d348-4c72-9082-7c61861cada3/824aff63-d348-4c72-9082-7c61861cada31.gif)
0.571230
2.4053E-02
1.0
0.529051
0.551819
2.2768E-02
当h=0.05时,解为:
0.05
0.950000
0.952418
2.4185E-03
0.10
0.904878
4.4835E-03
0.15
0.864158
0.870391
6.2326E-03
0.20
0.827406
7.6996E-03
0.25
0.794223
0.803138
8.9155E-03
0.30
0.764247
9.9084E-03
0.35
0.737147
0.747850
1.0704E-02
0.40
0.712621
1.1324E-02
0.45
0.690397
0.702188
1.1791E-02
0.50
0.670223
1.2124E-02
0.55
0.651876
0.664213
1.2338E-02
0.60
0.635148
1.2450E-02
0.65
0.619855
0.632328
1.2473E-02
0.70
0.605829
1.2420E-02
0.75
0.592918
0.605220
1.2302E-02
0.80
0.580985
1.2129E-02
0.85
0.569909
0.581819
1.1909E-02
0.90
0.559579
1.1651E-02
0.95
0.549896
0.561258
1.1362E-02
1.00
0.540771
1.1048E-02
h=50时,解为:
0.02
0.980000
0.980395
3.9471E-04
0.04
0.960792
0.961558
7.6599E-04
0.06
0.942345
0.943460
1.1148E-03
0.08
0.924628
0.926070
1.4422E-03
0.907613
1.7491E-03
0.12
0.891270
0.893306
2.0363E-03
0.14
0.875573
0.877878
2.3048E-03
0.16
0.860496
0.863051
2.5553E-03
0.18
0.846013
0.848802
2.7888E-03
0.832100
3.0058E-03
0.22
0.818732
0.821940
3.2073E-03
0.24
0.805889
0.809283
3.3938E-03
0.26
0.793547
0.797113
3.5662E-03
0.28
0.781685
0.785410
3.7250E-03
0.770284
3.8709E-03
0.32
0.759323
0.763328
4.0045E-03
0.34
0.748784
0.752911
4.1264E-03
0.36
0.738649
0.742886
4.2371E-03
0.38
0.728899
0.733236
4.3373E-03
0.719518
4.4274E-03
0.42
0.710490
0.714998
4.5079E-03
0.44
0.701800
0.706379
4.5793E-03
0.46
0.693431
0.698073
4.6421E-03
0.48
0.685371
0.690067
4.6967E-03
0.677603
4.7435E-03
0.52
0.670117
0.674900
4.7830E-03
0.54
0.662897
0.667713
4.8156E-03
0.56
0.655933
0.660775
4.8415E-03
0.58
0.649212
0.654073
4.8613E-03
0.642723
4.8751E-03
0.62
0.636454
0.641337
4.8835E-03
0.64
0.630395
0.635282
4.8866E-03
0.66
0.624537
0.629422
4.8848E-03
0.68
0.618868
0.623747
4.8784E-03
0.613381
4.8676E-03
0.72
0.608066
0.612918
4.8528E-03
0.74
0.602914
0.607748
4.8341E-03
0.76
0.597917
0.602728
4.8119E-03
0.78
0.593067
0.597853
4.7863E-03
0.588357
4.7577E-03
0.82
0.583779
0.588505
4.7261E-03
0.84
0.579326
0.584018
4.6918E-03
0.86
0.574992
0.579647
4.6550E-03
0.88
0.570771
0.575387
4.6159E-03
0.566656
4.5746E-03
0.92
0.562641
0.567172
4.5314E-03
0.94
0.558721
0.563207
4.4864E-03
0.96
0.554890
0.559330
4.4397E-03
0.98
0.551144
0.555535
4.3916E-03
0.547477
4.3420E-03
有图像看出,当步长越小,计算得到的解越逼近精确解。
1.2、求解初值问题
,已知精确解为:
,h=0.1
欧拉法
改进的欧拉法
预报-校正
格式
1.00483742
1.00000000
1.00500000
1.00476190
1.01873075
1.01000000
1.01925000
1.01859410
1.04081822
1.02900000
1.04183750
1.04063276
1.07032005
1.05610000
1.07194063
1.07009631
1.10653066
1.09049000
1.10881909
1.10627761
1.14881164
1.13144100
1.15180609
1.14853689
1.19658530
1.17829690
1.20030094
1.19629528
1.24932896
1.23046721
1.25376253
1.24902906
1.30656966
1.28742049
1.31170338
1.30626439
1.36787944
1.34867844
1.37368429
1.36757254
欧拉法图像:
改进欧拉法图像:
预测-校正法图像:
附录:
源代码
1.1、
clear
clc
X0=0;
X1=1;
n=10;
%更改分点数
h=1/n;
%步长
y
(1)=1;
x
(1)=X0;
fori=1:
n
x(i+1)=x(i)+h;
y(i+1)=y(i)+h*(x(i)*exp(-x(i))-y(i));
end
x=vpa(x'
6)
y=vpa(y'
X=(X0:
0.001:
X1);
n=1/0.001;
for(i=1:
n+1)
Y(i)=0.5*(X(i)^2+2)*exp(-X(i));
plot(x,y,'
*'
)
holdon
plot(X,Y)
X=X0:
h:
X1;
Y=0.5.*(X.^2+2).*exp(-X);
Y=vpa(Y'
yy=abs(y-Y)
1.2、
欧拉法:
Y=X+exp(-X);
9);
%精确解
XX=X0:
0.0001:
YY=XX+exp(-XX);
x(i+1)=x(i)+h;
y(i+1)=y(i)+h*(-y(i)+x(i)+1);
9)
plot(XX,YY)
改进的欧拉法:
y(i+1)=y(i)+h*(-y(i)+x(i)+1);
y(i+1)=y(i)+0.5*h*((-y(i)+x(i)+1)+(-y(i+1)+x(i+1)+1));
预报-校正格式:
forcount=1:
10%预报-校正格式,迭代十次
end