Nazorat savollari:
Chiziqsiz yoki transendent tenglama tushunchasi.
Chiziqsiz tenglama yechimining mavjudlik sharti.
Oraliqni teng ikkiga bo’lish usuli va uning algoritmi.
Vatarlar usuli va uning algoritmi.
Urinmalar usuli va uning algoritmi.
MA’RUZA:№ 4
Matematik modellashtirishdagi differensial tenglamalarni yechishdagi sonli usullar
Mavzu: Boshlang’ich shartli oddiy differensial tenglamalarni sonli yechish usullari.
Eyler usuli. [a,b] kesmada
y’=f(x,y)
differensial tenglamaning
y(a)=x0
boshlang’ich shartni qanoatlantiruvchi yechimini topish talab etilsin.
Eyler usulining mohiyati [a,b] kesmani n ta oraliqqa ajratamiz, ya’ni
xi=a+ih=xi-1+h, (x0=a)
nuqtalarni hosil qilamiz, bu yerda h=(b-a)/n
Funksiyaning bu nuqtalardagi qiymatlarini ushbu formula
yi=yi-1+hf(xi-1,yi-1)
bilan hisoblanadi.
Misol. tenglamaning [0,1] kesmada u(0)=1 boshlang’ich shartni qanoatlantiruvchi yechimining taqribiy qiymatlar jadvalini tuzing.
Echish. n=10, h=0,1 bo’lsin. Ushbu formuladan
,
yi ning qiymatlari topiladi, i=1,10.
i
|
xi
|
yi
|
f(xi,yi)
|
f(xi,yi)h
|
0
|
0
|
1
|
0
|
0
|
1
|
0,1
|
1
|
0,05
|
0,005
|
2
|
0,2
|
1,005
|
0,1005
|
0,0100
|
3
|
0,3
|
1,0150
|
0,1522
|
0,0152
|
4
|
0,4
|
1,0303
|
0,2061
|
0,0206
|
5
|
0,5
|
1,0509
|
0,2627
|
0,0263
|
6
|
0,6
|
1,0772
|
0,3232
|
0,0323
|
7
|
0,7
|
1,1095
|
0,3883
|
0,0388
|
8
|
0,8
|
1,1483
|
0,4593
|
0,0459
|
9
|
0,9
|
1,1942
|
0,5374
|
0,0537
|
10
|
1,0
|
1,2479
|
|
|
Aniq yechim: , , , , u(0)=1, S=1, , .
Differensial tenglamani Eyler usulida yechish uchun Paskal tilida tuzilgan dasturning ko’rinishi:
program eyler; uses crt;
var a,b,y:real; n:integer;
function f(x,y:real):real;
begin
f:=y-2*x*x+4*x-1 {f(x,y) funksiyasining ko’rinishi}
end;
procedure eyler_1(a,b,y:real;n:integer);
var h,x:real; i:integer;
begin
h:=(b-a)/n;
x:=a;
writeln('x=',x:6:2,' y=',y:8:4);
for i:=1 to n do
begin
y:=f(x,y)*h+y;
x:=x+h;
writeln('x=',x:6:2,' y=',y:8:4);
end;
end;
begin
clrscr;
write('a='); read(a);
write('b='); read(b);
write('n='); read(n);
write('y0='); read(y);
eyler_1(a,b,y,n);
end.
Runge-Kutta usuli. Ushbu
(1)
oddiy differensial tenglamalar sistemasi berilgan bo’lib, uning [a,b] oraliqdagi
y1(x0)=y10, y2(x0)=y20, …, yn(x0)=yn0 (2)
boshlang’ich shartni qanoatlantiruvchi yechimini topish talab qilinsin(x0=a).
Agar va belgilashlar kiritsak, (1) va (2) ni quyidagicha yozishimiz mumkin.
Y’ = F(x,Y) (3)
Y(x0) = Y0 (4)
Bu yerda .
(3) tenglamalar sistemasining (4) boshlang’ich shartni qanoatlantiruvchi yechimini Runge-Kutta usuli yordamida topamiz. Buning uchun xi=a+ih, Yi=F(xi), i=1,2,…,n belgilashlarni kiritib, quyidagi hisoblashlar ketma-ketligi bajaramiz:
(5)
Bu yerda h=(b-a)/n.
Bu hisoblashlar ketmaketligi i=1 dan n-1 gacha takroriy ravishda hisoblanadi, va (5) tenglikda differensial tenglamaning u=u(x) taqribiy yechimlari hosil bo’ladi.
Misol. Quyidagi
differensial tenglamalar sistemasini
boshlang’ich shartni qanoatlantiruvchi yechimini Runge-Kutta usulidan foydalanib toping (a=0, b=1, n=10 deb oling).
Yechish. Berilgan Koshi masalasi ushbu
aniq yechimga ega. Masalaning aniq va Runge-Kutta usuliga tuzilgan dastur yordamida topilgan taqribiy yechimlari quyidagi jadvalda keltirilgan.
|
|
|
aniq yechim
|
taqribiy yechim
|
aniq yechim
|
taqribiy yechim
|
0,0
|
-1.000000000
|
-1.000000000
|
1.000000000
|
1.000000000
|
0,1
|
-1.090000000
|
-1.090000000
|
0.890000000
|
0.889999166
|
0,2
|
-1.160000000
|
-1.160000084
|
0.760000000
|
0.759998408
|
0,3
|
-1.210000000
|
-1.210000253
|
0.610000000
|
0.609997710
|
0,4
|
-1.240000000
|
-1.240000511
|
0.440000000
|
0.439997058
|
0,5
|
-1.250000000
|
-1.250000862
|
0.250000000
|
0.249996438
|
0,6
|
-1.240000000
|
-1.240001315
|
0.040000000
|
0.039995840
|
0,7
|
-1.210000000
|
-1.210001877
|
-0.190000000
|
-0.190004750
|
0,8
|
-1.160000000
|
-1.160002561
|
-0.440000000
|
-0.440005343
|
0,9
|
-1.090000000
|
-1.090003380
|
-0.710000000
|
-0.710005952
|
1,0
|
-1.000000000
|
-1.000004350
|
-1.000000000
|
-1.000006587
|
Differensial tenglamalar sistemasi uchun Koshi masalasini Runge-Kutta usulida yechish uchun Paskal tilida tuzilgan dasturning ko’rinishi:
program rungi; uses crt;
const nurav=2;
type vector2=array[1..nurav] of real;
var
y0,y: vector2;
n,i,j:integer;
a,b,x0,x1,h:real;
procedure pv(x: real; y: vector2; var dy: vector2);
begin
dy[1]:=2*exp(-x)-y[1];
end;
procedure rungikytta(x: real; y0: vector2; var dy: vector2);
var v3,fc,fk1,fk2,fk3,fk4: vector2;
begin
pv(x,y0,fc);
for i:=1 to nurav do begin fk1[i]:=h*fc[i];
v3[i]:=y0[i]+0.5*fk1[i] end;
x:=x+0.5*h;
pv(x,v3,fc);
for i:=1 to nurav do begin fk2[i]:=h*fc[i];
v3[i]:=y0[i]+0.5*fk2[i] end;
pv(x,v3,fc);
for i:=1 to nurav do begin fk3[i]:=h*fc[i];
v3[i]:=y0[i]+fk3[i] end;
x:=x+0.5*h;
pv(x,v3,fc);
for i:=1 to nurav do begin fk4[i]:=h*fc[i];
dy[i]:=y0[i]+0.166666667*(fk1[i]+2*fk2[i]+2*fk3[i]+fk4[i]) end;
end;
begin clrscr;
write('a='); read(a);
write('b='); read(b);
write('n='); read(n);
h:=(b-a)/n;
x0:=a;
for i:=1 to nurav do
begin
write('y0[',i:1,']='); read(y0[i]);
end;
writeln; writeln;
write('x=',x0:5:2);
for i:=1 to nurav do write(' y[',i:1,']=',y0[i]:10:6);
writeln;
x1:=a;
for j:=1 to n do begin
rungikytta(x1,y0,y);
x1:=a+j*h;
write('x=',x1:5:2);
for i:=1 to nurav do write(' y[',i:1,']=',y[i]:10:6);
x0:=x1; y0:=y;
writeln;
end;
end.
Chegaraviy shartli oddiy differensial tenglamalarni yechish uchun oddiy progonka va differensial progonka usullari.
Oddiy progonka usuli. oraliqda
(1)
differensial tenglamaning
(2)
chegaraviy shartlarni qanoatlantiruvchi yechimini topish talab qilinsin. Bu yerda , - oraliqda berilgan uzluksiz funksiyalar bo’lib, - lar va shartlarni qanoatlantirsin.
Teorema. Agar , funksiyalar oraliqda ikki marta uzluksiz differensiallanuvchi va bo’lsa, (1), (2) chegaraviy masala yagona yechimga ega bo’ladi.
oraliqni nuqtalar bilan to’r(setka)ga ajratib, , , belgilashlarni kiritamiz. Ichki nuqtalar uchun chekli ayirmalardan foydalanib, aniqlikda (1) tenglamani
(3)
(2) chegaraviy shartni esa
(4)
ko’rinishda yozib olamiz.
(3) da ekanligini hisobga olib, uni (4) ga qo’yamiz va
tenglikni hosil qilib, uni
ko’rinishda yozib olamiz. Bu yerda , .
Xuddi shunga o’xshash (3) da ekanligini hisobga olib, uni (4) ga qo’yamiz va
tenglikni hosil qilib, uni
(5)
ko’rinishda yozib olamiz. Bu yerda , .
(3) va (4) birgalikda – noma’lumlarni o’z ichiga olgan ta chiziqli algebraik tenglamalar sistemasini tashkil etadi.
Agar sistemani
,
matrisa ko’rinishida ifodalasak, uchta diagonalidagi elementlar noldan farqli matrisa (uchdiagonalli matrisa) bo’ladi. Bu sistemani Gauss, Kramer, teskari matrisa usullari bilan yechish yaxshi samara bermaydi. Shu sababli bu sistemani yechish uchun progonka usulidan foydalanamiz.
Umumiy
, (6)
ko’rinishdagi uchdiagonalli tenglamalar sistemasi berilgan bo’lsin. Bu yerda lar ga bog’liq o’zgarmaslar.
(6) ning yechimini
, (7)
ko’rinishda ifodalaymiz. Bu yerda - lar ma’lum, - lar esa hozircha noma’lum koeffisientlar.
(7) da ni ga almashtirib, ga ega bo’lamiz va o’rniga uning (7) dagi ifodasini olib kelib qo’yamiz. Natijada
, (8)
tenglikni hosil qilamiz. (7), (8) larni (6) ga olib borib quyib,
tenglikga ega bo’lamiz. Bu tenglikda oldidagi koeffisientlarni hamda ozod hadlarni nolga tenglashtirib,
tengliklarni hosil qilamiz. Bu yerdan larni hisoblash uchun
(9)
formulalarga ega bo’lamiz. (9) to’g’ri progonka formulasi deb ataladi va u larni bilgan holda larni hisoblash imkonini beradi.
larning qiymatlarini aniqlab, ularni (5) ga qo’ysak, natijada
yoki
ga ega bo’lamiz. ni bilgan holda, (7) formula yordamida larning qiymatlarini hisoblaymiz. Bu amal teskari progonka deb ataladi.
Teorema (progonka usulining turg’unligi haqida). Agar ; shartlar bajarilsa progonka usuli turg’un bo’ladi.
Misol.
differensial tenglamaning
chegaraviy shartni qanoatlantiruvchi yechimini berilgan dastur yordamida aniqlang.
Tekshirib ko’rish mumkinki, berilgan chegaraviy masala aniq yechimga ega. Quyidagi jadvalda masalaning ni ayrim tugun nuqtalariga mos keluvchi taqribiy va aniq yechimlari qiymatlari keltirilgan.
|
0,0
|
0,1
|
0,2
|
0,3
|
0,4
|
0,5
|
0,6
|
0,7
|
0,8
|
0,9
|
1,0
|
Taq. yechim
|
0,986
|
1,089
|
1,193
|
1,302
|
1,417
|
1,540
|
1,673
|
1,819
|
1,978
|
2,153
|
2,345
|
Aniq yechim
|
1,000
|
1,100
|
1,203
|
1,309
|
1,421
|
1,542
|
1,672
|
1,814
|
1,971
|
2,143
|
2,333
|
Paskal tilida progonka usuliga tuzilgan dastur matni:
program progonka;
const a1=0; b1=1; m=10; h=(b1-a1)/m;
alfa0=0.5; alfa1=0.5; alfa2=1.0;
betta0=-3.0; betta1=2.0; betta2=-3.0;
type vektor=array[0..m] of real;
var
x,y,a,b,c,r,d,e:vektor;
i:integer;
q,s,g1,g2:real;
function fq(t:real):real;
begin
fq:=2-t { funksiyasining berilishi}
end;
function fr(t:real):real;
begin
fr:=-sqr(sqr(t))/3+2*t*sqr(t)/3-sqr(t)+3*t+2 {r(x) funksiyasining berilishi}
end;
begin
for i:=0 to m do begin
x[i]:=a1+i*h; a[i]:=1.0; b[i]:=1.0;
c[i]:=2-fq(x[i])*sqr(h); r[i]:=fr(x[i])*sqr(h)
end;
g1:=2*(alfa1-alfa0*h); e[1]:=alfa1*(2+fq(x[1])*sqr(h))/g1;
d[1]:=-h*(2*alfa2+alfa1*fr(x[1])*h)/g1;
for i:=1 to m-1 do begin
e[i+1]:=b[i]/(c[i]-a[i]*e[i]); d[i+1]:=(a[i]*d[i]-r[i])/(c[i]-a[i]*e[i]);
end;
g2:=2*(betta1+betta0*h); q:=betta1*(2+fq(x[m-1])*sqr(h))/g2;
s:=(2*h*betta2-betta1*fr(x[m-1])*sqr(h))/g2;
y[m]:=(q*d[m]+s)/(1-q*e[m]);
for i:=m-1 downto 0 do y[i]:=e[i+1]*y[i+1]+d[i+1];
for i:=0 to m do writeln('y[',i:1,']=',y[i]:6:4);
end.
Differensial progonka usuli. Differensial progonka usuli algoritmini quyidagi berilgan misolda ko’rib chiqamiz. Ushbu
(10)
differensial tenglamaning
(11)
chegaraviy shartlarni qanoatlantiruvchi yechimini topish talab qilinsin. Bu yerda –o’zgarmaslar; – oraliqda berilgan uzluksiz funksiyalar. – noma’lum funksiya.
Differensial progonka usuliga ko’ra (10), (11) chegaraviy masala yechimini
(12)
ko’rinishda tasvirlaymiz. Bu yerdagi lar xozircha noma’lum funksiyalar. (12) ni (10) ga olib borib qo’yamiz va larga nisbatan quyidagi
(13)
birinchi tartibli differensial tenglamalar sistemasini hosil qilamiz.
va
tengliklardan
(14)
ni hosil qilamiz.
(13), (14) Koshi masalasini oraliqda yechib, larni aniqlaymiz. Odatda bu usul to’g’ri progonka usuli deb ham ataladi.
va
tengliklardan
, (15)
ga ega bo’lamiz.
(10), (15) Koshi masalasini oraliqda yechib, funksiyasining sonli qiymatlarini hosil qilamiz. Bu usul teskari progonka usuli deyiladi.
Misol: Quyidagi
(16)
differensial tenglamaning
(17)
shartlarni qanoatlantiruvchi yechimini differensial progonka usuliga tuzilgan dastur yordamida toping.
Tekshirib ko’rish mumkinki, berilgan chegaraviy masala aniq
yechimga ega. Quyidagi jadvalda (5.50), (5.51) chegaraviy masalaning aniq va differensial progonka usulidan foydalanib topilgan taqribiy yechimlari keltirilgan. Jadvaldan ko’rinib turibdiki, differensial progonka usuli yuqori aniqlikga ega bo’lishi bilan birga, u chegaraviy shartlarni aniq hisobga oladi.
|
Aniq yechim
|
Taqribiy yechim
|
0.0
|
1.000000
|
1.000121
|
0.1
|
0.911000
|
0.911107
|
0.2
|
0.848000
|
0.848091
|
0.3
|
0.817000
|
0.817073
|
0.4
|
0.824000
|
0.824054
|
0.5
|
0.875000
|
0.875035
|
0.6
|
0.976000
|
0.976015
|
0.7
|
1.133000
|
1.132997
|
0.8
|
1.352000
|
1.351980
|
0.9
|
1.639000
|
1.638965
|
1.0
|
2.000000
|
2.000000
|
Chegaraviy masalalarni differensial progonka usulida yechishga Paskal tilida tuzilgan dastur matni:
program difprogon; uses crt;
const a11=1; a12=1; a21=1; a22=-1; b1=0; b2=2;
ndx=11; dx=0.1;
type vek=array[1..ndx] of real;
type vek1=array[1..2] of real;
type vek2=array[1..3] of real;
var
y0,y,yt: vek1; alf0,alf: vek2; px: vek; zlx,h:real;
i,nx:integer;
function fa(z: real): real;
begin
fa:=z+1; { A(x) - funksiyasining ko’rinishi }
end;
function fb(z: real): real;
begin
fb:=z+3; { B(x) - funksiyasining ko’rinishi }
end;
function ff(z: real): real;
begin
ff:=z*z*z*z+7*z*z*z+7*z*z+5*z+4; { -funksiyasining ko’rinishi }
end;
procedure pv(x: real; y: vek2; var dy: vek2);
begin
dy[1]:=fa(x)*y[1]-y[2];
dy[2]:=y[1]*fb(x);
dy[3]:=y[1]*ff(x)
end;
procedure rungikytta1(x: real; y0: vek2; var dy: vek2);
var v3,fc,fk1,fk2,fk3,fk4: vek2;
begin
pv(x,y0,fc);
for i:=1 to 3 do begin fk1[i]:=h*fc[i];
v3[i]:=y0[i]+0.5*fk1[i] end;
x:=x+0.5*h;
pv(x,v3,fc);
for i:=1 to 3 do begin fk2[i]:=h*fc[i];
v3[i]:=y0[i]+0.5*fk2[i] end;
pv(x,v3,fc);
for i:=1 to 3 do begin fk3[i]:=h*fc[i];
v3[i]:=y0[i]+fk3[i] end;
x:=x+0.5*h;
pv(x,v3,fc);
for i:=1 to 3 do begin fk4[i]:=h*fc[i];
dy[i]:=y0[i]+0.166666667*(fk1[i]+2*fk2[i]+2*fk3[i]+fk4[i]) end;
end;
procedure pv1(x: real; y: vek1; var dy: vek1);
begin
dy[1]:=y[2];
dy[2]:=-y[2]*fa(x)-y[1]*fb(x)+ff(x);
end;
procedure rungikytta2(x: real; y0: vek1; var dy: vek1);
var v3,fc,fk1,fk2,fk3,fk4: vek1;
begin
pv1(x,y0,fc);
for i:=1 to 2 do begin fk1[i]:=h*fc[i];
v3[i]:=y0[i]+0.5*fk1[i]
end;
x:=x+0.5*h; pv1(x,v3,fc);
for i:=1 to 2 do begin fk2[i]:=h*fc[i];
v3[i]:=y0[i]+0.5*fk2[i]
end;
pv1(x,v3,fc);
for i:=1 to 2 do begin fk3[i]:=h*fc[i];
v3[i]:=y0[i]+fk3[i]
end;
x:=x+0.5*h; pv1(x,v3,fc);
for i:=1 to 2 do begin fk4[i]:=h*fc[i];
dy[i]:=y0[i]+0.166666667*(fk1[i]+2*fk2[i]+2*fk3[i]+fk4[i])
end;
end;
begin clrscr;
for i:=1 to ndx do px[i]:=(i-1)*dx;
alf0[1]:=a11; alf0[2]:=a12; alf0[3]:=b1;
for nx:=2 to ndx do begin zlx:=px[nx-1]; h:=dx;
rungikytta1(zlx,alf0,alf);
for i:=1 to 3 do alf0[i]:=alf[i];
end;
y0[1]:=(b2*alf[1]-a21*alf[3])/(a22*alf[1]-a21*alf[2]);
y0[2]:=(b2*alf[2]-a22*alf[3])/(a21*alf[2]-a22*alf[1]);
writeln('x=',px[ndx]:4:2,' yy===',y0[1]:7:4);
for nx:=ndx downto 2 do begin zlx:=px[nx]; h:=-dx;
rungikytta2(zlx,y0,y);
writeln('x=',(zlx+h):4:2,' yy=',y[1]:7:4);
for i:=1 to 2 do y0[i]:=y[i];
end; end.
Nazorat savollari:
Differensial tenglama uchun chegaraviy shartlar qanday beriladi?
Oddiy progonka usuli va uning algoritmi.
Differensial progonka usuli va uning algoritmi.
Differensial progonka usulining asosiy mohiyati nimadan iborat?
|