100 FOR I=1 TO N
110 Y=Y+H*FNE(X,Y):Y(I)=Y
120 X=X+H:X(I)=X
130 PRINT " y(";USING "##.##";X;
140 PRINT ")=";USING "###.#####";Y
150 NEXT I
160 FOR I=1 TO N
170 PSET(X(I)*60+250,-Y(I)*60*.64+136),3
180 NEXT I
190 FOR X1=X(1) TO X(N) STEP .01
200 S=0
210 FOR I=1 TO N :P=1 : FOR J=1 TO N
220 IF I=J THEN 240
230 P=P*(X1-X(J))/(X(I)-X(J))
240 NEXT J
250 S=S+P*Y(I)
260 NEXT I
270 Y1(X1)=S:FOR R=1 TO 35000!:NEXT R
280 PSET(X1*60+250,-Y1(X1)*60*.64+136),5
290 NEXT X1
300 END
9.1- Paskal tili dasturi
{Birinchi tartibli differentsial tenglama }
{Y1=F(X,Y) uchun}
{Koshi masalasini Eyler usulida}
{taqribiy yechimini topish}
Uses Crt;
function fne(x,y:real):real;
begin fne:=x+cos(y/sqrt(5)) end;
var x,y,y1,h,b,EPS:real;
i,n:integer;
begin
write(' x=',' y=',' h=',' b=');readln(x,y,h,b);
n:=trunc((b-x)/h);
for i:=1 to n do
begin
y:=y+h*fne(x,y);
x:=x+h;
writeln;
write(' x=(',i:2,')=',x:8:4);
write(' y=(',i:2,')=',x:8:4);
end;
end.
2. Tenglama yechimini Eylerning ketma-ket yaqinlashish usulida hisoblaymiz. (9.6) formulada i=0 bo‘lganda
y1(0)=y0+hf (x0;y0)=y0+k (x0+cos(y0/ ))=
=2.6+ 0.1(9.8+cos(9.6/ ))=2.6+0.1(9.8+0.3968)=2.81968
bo‘ladi. Bu Eyler usulidagi tenglama yechimining birinchi qiymati bo‘ladi.
Endi y1(0)=2.81968 dan foydalanib (9.7) formulaga asosan i=1 bo‘lganda
y1(k)= y0+ [f (x0, y0)+ f (x1,y1(k-1))]
formulani k = 1,2,3,….. lar uchun ketma-ket
y1(1), y1(2), y1(3), …, y1(k)
larni
y1(k-1) – y1(k) < 0.001
shartni qanoatlantirguncha hisoblaymiz.
Demak,
k=1, y1(1)=y0+ [f (x0,y0)+f (x1,y1(0))]=2.6+0.05[2.1968+x1+cos (y1(0)/ )] =
=2.6+0.05[2.1968+1.9+0.36486] =2.7102
k=2, y1(2)= 2.6+0.05[2.1968+x1+cos(y1(1)/ )] =
=2.6+0.05[2.1968+1.9+ cos(9.7102/ )] =2.82239
k=3, y1(3)= 2.6+0.05[2.1968+1.9+cos(9.83339/ )] =
=2.6+0.05[2.1968+1.9+ 0.303709] =2.82002
Endi xatolikni tekshiramiz.
y1(2) – y1(3) =2.8223 – 2.82202=0.0002< 0.001
Bundan 0.001 aniqlikdagi tenglama yechimining birinchi qiymati
y1 = 2.82000 2.82
bo‘ladi.
Tenglama yechimi y2 qiymatini topish uchun yuqoridagi qoidani takrorlaymiz.
i=1 uchun (9.6) formulaga asosan
y2(0)= y1 + hf (x1, y1) = 2.82 + 0.1(x1+cos (y1/ )) =
=2.82+0.1(9.9+cos(9.82/ ) = 3.04047
i=1 uchun (9.7) formulaga asosan
k=1, y2(1)= y1+ [f (x1, y1)+ f (x2, y2(0))] =
=2.82+0.05[2.20471+2+cos(3.0404/ )] =3.0407
k=2, y2(2)=y1+ [f (x1,y1)+f (x2,y2(2))]= y1+ [2.20471+2+ cos(u2(1)/ )]=
=2.82+0.05[2.20471+2+cos(3.0407/ )] =3.04071
k=3, y2(3)= y1+ [f (x1, y1)+ f (x2, y2(2))] =
=2.82+0.05[2.20471+2+cos (3.0407/ )] =
=2.82+0.05[2.20471+2+cos (3.0407/ )] =3.0407
Endi xatolikni baholaymiz.
y 1(2) – y 1(3) =3.04071 – 3.04070=0.0001< 0.001
Bundan tenglama yechimining ikkinchi qiymati
y2 = 3.0407
bo‘ladi.
Bu qoidani i=2,3,…,10 lar uchun ketma-ket davom ettirib tenglama yechimining qolgan qiymatlarini ham topamiz.
y3=3.261, y4=3.483, y5=3.704, y6=3.926
y7=4.147, y8=4.370, y9=4.593, y10=4.817
Bu usul yordamida hisoblash quyidagicha dastur asosida berilgan.
8 ‘------- 9.2- dastur------------
10 DEF FNE (X,Y)=X+COS(Y/SQR (5))
14 RRINT “Birinchi tartibli differentsial tenglama ”
15 PRINT “ Y1=F(X,Y) uchun”
16 PRINT “Koshi masalani Eylerning ketma-ket yaqinlashish”
18 PRINT “ usulida taqribiy yechimini topish”
20 REM “boshlang’ich qiymat ,qadam, berilgan kesma yuqori chegarasi:”
22 READ X, Y, H, B: EPS=0.0001
24 REM “boshlang’ich qiymat ,qadam, berilgan kesma yuqori chegarasi qiymatlari:”
26 DATA 1.8, 2.6, 0.1, 2.8
50 N=(B-X)/H
60 FOR I=1 TO N
70 Y1=Y
80 Y=Y+H*FNE(X,Y)
90 Z=Y
100 Y=Y1+(FNE(X,Y1)+FNE(X+H,Z))*H/2
102 X=X+H
110 IF ABS (Z-Y)>EPS THEN 80
120 PRINT “X (“;USING “###.###”;I
130 PRINT “)=”;USING “###.###”;X;
140 PRINT “ Y(“;USING “###.###”;I;
150 PRINT “)=”;USING “###.###”;Y
160 PRINT “ Z(“;USING “###.###”;I;
170 PRINT “)=”;USING “###.###”;Z
180 NEXT I
200 END
Birinchi tartibli differentsial tenglama
Y1=F(x,y) uchun
Koshi masalasini Eylerning ketma-ket yaqinlashish
usulida taqribiy yechimini topish.
X(1)=1.900 Y(1)=2.8197 Z(1)=2.8197
Do'stlaringiz bilan baham: |