不知理解对否?
这道微分方程组题与一般相比,不同之处是初值不是同时知道,及x=0时y2, y3已知,y1,y4未知;而x=3时,y1, y4已知,y2, y3未知,不能按一般的初值微分方程求解。参照帖子:用1stOpt求解常微分方程及方程组(http://forum.vibunion.com/forum/thread-61555-1-1.html),试着用1stOpt求解:
Constant y2_1=0, y3_1=20, y1=0, y4=0, dx=0.1;
Parameter y1_1, y4_1;
PassParameter Out_x(0:30), Out_11(0:30), Out_22(0:30), Out_33(0:30), Out_44(0:30);
Plot Out_x[x], Out_11, Out_22, Out_33, Out_44;
Minimum;
StartProgram [Pascal];
Procedure MainModel;
var i: integer;
y1_2, y2_2, y3_2, y4_2: double;
y11, y21, y31, y41: double;
begin
y11:=y1_1;
y21:=y2_1;
y31:=y3_1;
y41:=y4_1;
Out_x[0] := 0;
Out_11[0] := y11;
Out_22[0] := y21;
Out_33[0] := y31;
Out_44[0] := y41;
for i := 0 to 29 do begin
y1_2:=y11+y21*dx;
y2_2:=y21+20*(y31-y11)*dx;
y3_2:=y31+y41*dx;
y4_2:=y41+(8.4+2+8*(y31-y11))*dx;
y11:=y1_2;
y21:=y2_2;
y31:=y3_2;
y41:=y4_2;
Out_x[i+1] := dx*(i+1);
Out_11[i+1] := y11;
Out_22[i+1] := y21;
Out_33[i+1] := y31;
Out_44[i+1] := y41;
end;
functionResult := sqr(y1_2-y1)+sqr(y4_2-y4);
end;
EndProgram;
结果:
x y1 y2 y3 y4
0 20.4612109325425 0 20 -12.9637651392588
.1 20.4612109325425 -.922421865085013 18.7036234860741 -12.2927338852929
.2 20.368968746034 -4.4375967580218 17.4743500975448 -12.6588038424676
.3 19.9252090702318 -10.2268340550002 16.2084697132981 -13.9344987612589
.4 18.9025256647318 -17.6603127688677 14.8150198371722 -15.8678902468059
.5 17.136494387845 -25.8353244239869 13.2282308124916 -18.0978949088536
.6 14.5529619454464 -33.6518515746938 11.4184413216062 -20.1845057691364
.7 11.187776787977 -39.9208928223741 9.39999074469259 -21.6521222682085
.8 7.19568750573956 -43.4964649089428 7.23477851787174 -22.042351102836
.9 2.84604101484528 -43.4182828846785 5.03054340758815 -20.9710782931302
1 -1.49578727362257 -39.0492780991927 2.93343557827512 -18.1834763789359
1.1 -5.40071508354184 -30.1908323953974 1.11508794038153 -13.6000980974178
1.2 -8.41979832308158 -17.1592263475506 -.244921869360252 -7.3474556782791
1.3 -10.1357209578366 -.809473440107978 -.979667437188162 .23244548469796
1.4 -10.2166683018474 17.502633601189 -.956422888718366 8.59728830121674
1.5 -8.46640494172854 36.0231244274471 -9.66940585966919E-02 17.04548463172
1.6 -4.86409249898383 52.7625461937108 1.60785440457531 24.7812533382255
1.7 .412162120387253 65.7064400008291 4.08597973839786 30.9988108610728
1.8 6.98280612047016 73.0540752368503 7.18586082450513 34.9778649554813
1.9 14.2882136441552 73.4601846449202 10.6836473200533 36.1803087187092
2 21.6342321086472 66.2510519967164 14.3016781919242 34.3366556594277
2.1 28.2593373083188 51.5859441632703 17.735343757867 29.5106125260493
2.2 33.4179317246459 30.5379570623665 20.6864050104719 22.1314176856878
2.3 36.4717274308825 5.07490363401854 22.8995467790407 12.9861963143486
2.4 36.9792177942844 -22.0694576696652 24.1981664104755 3.16845179287506
2.5 34.7722720273179 -47.631560437283 24.515011589763 -6.01638931417204
2.6 30.0091159835896 -68.1460813123927 23.9133726583458 -13.1821976642159
2.7 23.1945078523503 -80.3375679628802 22.5951528919242 -17.0187923244109
2.8 15.1607510560623 -81.5362778837324 20.8932736594831 -16.4582762927518
2.9 7.00712326768905 -70.0712326768907 19.247446030208 -10.8322582100151
3 -1.59872115546023E-14 -45.5905871518529 18.1642202092064 -1.27849120179491E-15
如果把步长dx变小,计算部分再运用龙格库塔法,精度会提高不少。 |