1-laboratoriya ishi mavzu: Turli modellar tuzishga doir misollar yechish. Kerakli texnik vositalar


Download 1.87 Mb.
bet12/15
Sana27.12.2022
Hajmi1.87 Mb.
#1067790
1   ...   7   8   9   10   11   12   13   14   15
Bog'liq
Labaratoriya modellashtirish

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‘ѓ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: Ќuyidagi
(16)
differensial tenglamaning
(17)
shartlarni qanoatlantiruvchi yechimini differensial progonka usuliga tuzilgan dastur yordamida toping.
Tekshirib ko‘rish mumkinki, berilgan chegaraviy masala aniq

yechimga ega. Ќuyidagi 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.
Ishni bajarish tartibi:

  1. Berilgan masalaning yechish algoritmini blok-sxema ko‘rinishda tasvirlash.

  2. Turbo-Paskal muhitida dasturni kiritish.

  3. Dasturni kompyuter xotirasida saqlash va dasturdagi mavjud xatolarni topish va ularni to‘ѓrilash.

  4. Dasturni ishga tushirish va masalaning boshlanѓich ma’lumotlarini kiritib natijalar olish.

  5. Olingan natijalar tahlili asosida xulosalar qilish.

  6. Laboratoriya ishini rasmiylashtirish.



Nazorat savollari:

  1. Differensial tenglama uchun chegaraviy shartlar qanday beriladi?

  2. Oddiy progonka usuli va uning algoritmi.

  3. Differensial progonka usuli va uning algoritmi.

  4. Differensial progonka usulining asosiy mohiyati nimadan iborat?

11-LABORATORIYA ISHI


Mavzu: Integral va integro-differensial tenglamalarni taqribiy yechish usullari.
Kerakli texnik vositalar:
Shaxsiy kompyuter.
Kerakli dasturiy vositalar:
Turbo Paskal dasturlash sistemasi hamda integral va integro-differensial tenglamalarni taqribiy yechish uchun tuzilgan dasturlar.
Ishning maqsadi: Talabalarni integral va integro-differensial tenglamalarni taqribiy yechish usullari algoritmi bilan tanishtirish hamda ularni Paskal tilida tuzilgan dasturda ishlashga o‘rgatish.


Topshiriq
1-masala. Ќuyida berilgan 1-tur Volterra tenglamasini taqribiy yeching.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
2-masala. Ќuyida berilgan 2-tur Volterra tenglamasini taqribiy yeching.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
3-masala. Ќuyida berilgan 1-tur Fredgolm tenglamasini taqribiy yeching.
1. 2.
3. 4.
5. 6.
7. 8.
9. 10.
4-masala. Ќuyida berilgan 1-tur Fredgolm tenglamasini taqribiy yeching.
1. 2.
3. 4.
5. 6.
7.
8. 9. 10.


Nazariy qism
1-tur Voltera tenglamasi. Chiziqli 1-tur Volterra tenglamasi quyidagi
, (1)
ko‘rinishga ega.
Teorema. Agar , bo‘lib , funksiyalar oraliqda uzluksiz , hosilalarga ega hamda bo‘lsa, (1) tenglama shu oraliqda uzluksiz yagona yechimga ega bo‘ladi.
(1) tenglamani yechishda kvadratura formulasidan foydalanamiz. Dastlab (1) tenglamaning ikkala tomonini bo‘yicha bir marta differensiallab, hosil bo‘lgan ifodada desak,
(2)
tenglikni hosil qilamiz. (1) tenglamadagi integralni o‘zgarmas qadamli trapesiya formulasi bo‘yicha chekli yiѓindiga almashtirib, quyidagi
, (3)
rekurrent formulaga ega bo‘lish mumkin. Bu yerda , , lar uchun .
(2) va (3) formulalar yordamida larni ketma-ket aniqlash mumkin.
Misol. Tuzilgan dasturdan foydalanib berilgan , , lar uchun olingan (6.2) integral tenlamaning taqribiy va aniq yechimlari har xil larda quyidagi jadvalda keltirilgan.



Taqribiy yechim

Aniq yechim

0,0
0,2
0,4
0,6
0,8
1,0
1,2
1,4
1,6
1,8
2,0
2,2
2,4
2,6
2,8
3,0

0,000000
0,197000
0,370889
0,503031
0,582535
0,607539
0,584365
0,525031
0,444020
0,355225
0,269770
0,194969
0,134354
0,088411
0,055624
0,033494

0,000000
0,196040
0,369247
0,501162
0,580919
0,606531
0,584103
0,525436
0,444860
0,356218
0,270671
0,195628
0,134723
0,088523
0,055555
0,033327

Chiziqli 1-tur Volterra tenglamasini yechish uchun Paskal tilida tuzilgan dastur matni:


program volter_1; uses crt;
const
a=0.0; { ning boshlanѓich qiymati }
n=31; { bo‘yicha no‘qtalar soni }
h=0.1; { bo‘yicha qadam }
type vek=array[1..n] of real;
var y,t,c:vek;
s:real;i,j:integer;
function f(x:real):real;
begin
f:=x*x { funksiya ko‘rinishi }
end;
function f1(x:real):real;
begin
f1:=2*x { funksiya ko‘rinishi }
end;
function r(x,y:real):real;
begin
r:=2+x*x-y*y { funksiya ko‘rinishi }
end;
begin clrscr;
for i:=1 to n do begin t[i]:=a+(i-1)*h; c[i]:=1.0 end;
c[1]:=0.5;
y[1]:=f1(a)/r(a,a); toch[1]:=ftoch(a);
for i:=2 to n do
begin
s:=0;
for j:=1 to i-1 do s:=s+c[j]*r(t[i],t[j])*y[j];
y[i]:=2/r(t[i],t[i])*(f(t[i])/h-s);
end;
for i:=1 to n do writeln(t[i]:5:2,' ',y[i]:10:6);
end.
2-tur Voltera tenglamasi.Chiziqli, bir jinsli bo‘lmagan 2-tur Volterra tenglamasi quyidagi
, (4)
ko‘rinishga ega. Bu yerda - yadro funksiyasi, , , chiziqlar bilan chegaralangan uchburchak ichida va uning chegarasida uzluksiz. funksiya oraliqda uzluksiz. - noma’lum funksiya.
(4) tenglamani yechishda kvadratura formulasidan foydalanamiz. (4) tenglamadagi integralni o‘zgarmas qadamli trapesiya formulasi bo‘yicha chekli yiѓindiga almashtirib, quyidagi
, (5)
rekurrent formulaga ega bo‘lish mumkin. Bu yerda , , lar uchun . Agar (4) tenglamada desak,
(6)
tenglikga ega bo‘lamiz.
(5) va (6) formulalar yordamida larni ketma-ket aniqlash mumkin.
Misol. Tuzilgan dasturdan foydalanib, berilgan , , , lar uchun olingan (4) integral tenlamaning taqribiy va aniq yechimlari har xil larda quyidagi jadvalda keltirilgan.





Taqribiy yechim

Aniq yechim

0,0
0,2
0,4
0,6
0,8
1,0
1,2
1,4
1,6
1,8
2,0

-0,301169
-0,983602
-2,101015
-3,669153
-5,284334
-5,513842
-1,309168
10,545296
25,010640
14,346203
-45,527236

-0,301169
-0,983569
-2,100915
-3,668947
-5,284021
-5,513636
-1,309882
10,542137
25,006065
14,355014
-45,489898

Chiziqli 2-tur Volterra tenglamasini yechish uchun Paskal tilida tuzilgan dastur matni:


program volter_2; uses crt;
const
a=0.0; { ning boshlanѓich qiymati }
n=21; { bo‘yicha nuqtalar soni }
h=0.05; { bo‘yicha qadam }
type vek=array[1..n] of real;
var y,t,c:vek;
s:real;i,j:integer;
function f(x:real):real;
begin
f:=(1-x*exp(2*x))*cos(1)-exp(2*x)*sin(1) { funksiya ko‘rinishi }
end;
function r(x,y:real):real;
begin
r:=1-(x-y)*exp(2*x) { funksiya ko‘rinishi }
end;
begin clrscr;
for i:=1 to n do begin t[i]:=a+(i-1)*h; c[i]:=1.0 end;
c[1]:=0.5;
y[1]:=f(a);
for i:=2 to n do
begin
s:=0;
for j:=1 to i-1 do s:=s+c[j]*r(t[i],t[j])*y[j];
y[i]:=(f(t[i])+h*s)/(1-h*r(t[i],t[i])/2);
end;
for i:=1 to n do writeln(t[i]:5:2,' ',y[i]:10:6);
end.
Fredgolm tipidagi tenglamalar. Umumiy holda chiziqli, bir jinsli bo‘lmagan Fredgolm tipidagi integral tenglamalar
(7)
ko‘rinishga ega. Bu yerda , - yadro funksiyasi kvadratda aniqlangan va uzluksiz.
(7) da, agar va bo‘lsa, 1-turdagi; agar va bo‘lsa, 2-turdagi Fredgolm integral tenglamalari hosil bo‘ladi.
lar uchun, (7) dagi integralni o‘zgarmas qadam bilan trapesiya formulasiga almashtirsak,
, (8)
tenglikga ega bo‘lamiz. Bu yerda , , , , , lar uchun .
(8) da Kroneker belgilashini kiritsak, ixtiyoriy lar uchun
(9)
ta noma’lumlarni o‘z ichiga olgan ta chiziqli algebraik tenglamalar sistemasiga ega bo‘lamiz. (9) chiziqli algebraik tenglamalar sistemasini Gauss usulida yechib larni aniqlaymiz.
Misol. Tuzilgan dasturdan foydalanib berilgan , , , , , , lar uchun olingan (7) integral tenlamaning taqribiy va aniq yechimlari har xil larda quyidagi jadvalda keltirilgan.





Taqribiy yechim

Aniq yechim

-3,141593
-2,792527
-2,443461
-2,094395
-1,745329
-1,396263
-1,047198
-0,698132
-0,349066
-0,000000
0,349066
0,698132
1,047198
1,396263
1,745329
2,094395
2,443461
2,792527
3,141593

16,029411784
14,267864029
9,807468605
4,735294098
1,424667324
1,424667340
4,735294138
9,807468648
14,267864050
16,029411768
14,267864050
9,807468648
4,735294138
1,424667340
1,424667324
4,735294098
9,807468605
14,267864029
16,029411784

16,029411765
14,267864011
9,807468590
4,735294086
1,424667316
1,424667334
4,735294133
9,807468644
14,267864046
16,029411765
14,267864046
9,807468644
4,735294133
1,424667334
1,424667316
4,735294086
9,807468590
14,267864011
16,029411765

Fredgolm tipidagi integral tenglamalarini yechish uchun Paskal tilida tuzilgan dastur matni:


program fredgolm;
const alfa=1; { ning qiymati }
lambda=1; { ning qiymati }
n=37; { bo‘yicha nuqtalar soni }
a=-3.14159265; { ning boshlanѓich qiymati }
b=-a; { ning oxirgi qiymati }
type
matrisa=array[1..n,1..n+1] of real;
vektor=array[1..n] of real;
var
aij:matrisa; t,y,c:vektor;
h:real;i,j:integer;
function f(x:real):real;
begin
f:=25-16*sqr(sin(x)) { funksiyaning berilishi }
end;
function fk(x,s:real):real;
begin
fk:=0.3/(0.64*pi*sqr(cos((x+s)/2))-pi) { funksiyaning berilishi }
end;
function d(l,m:integer):integer;
begin
if l=m then d:=1 else d:=0; { funksiyaning berilishi }
end;
procedure gauss(b:matrisa; var y:vektor);
var max,c:real; k,m:integer;
begin
for i:=1 to n do
begin
max:=abs(b[i,i]); j:=i;
for k:=i+1 to n do if abs(b[k,i])>max then
begin
max:=abs(b[k,i]); j:=k;
end;
if j<>i then for k:=i to n+1 do
begin
c:=b[i,k]; b[i,k]:=b[j,k];
b[j,k]:=c;
end;
c:=b[i,i];
for k:=i to n+1 do b[i,k]:=b[i,k]/c;
for m:=i+1 to n do
begin
c:=b[m,i];
for k:=i+1 to n+1 do
b[m,k]:=b[m,k]-b[i,k]*c;
end;
end;
y[n]:=b[n,n+1];
for i:=n-1 downto 1 do
begin
y[i]:=b[i,n+1];
for k:=i+1 to n do
y[i]:=y[i]-b[i,k]*y[k]
end;
end;
begin
h:=(b-a)/(n-1);
for i:=1 to n do begin t[i]:=a+(i-1)*h; c[i]:=1 end;
c[1]:=0.5; c[n]:=0.5;
for i:=1 to n do for j:=1 to n do
aij[i,j]:=alfa*d(i,j)-h*lambda*c[j]*fk(t[i],t[j]);
for i:=1 to n do aij[i,n+1]:=f(t[i]);
gauss(aij,y);
for i:=1 to n do writeln('t=',t[i]:8:6,' ',y[i]:10:9);
end.

Download 1.87 Mb.

Do'stlaringiz bilan baham:
1   ...   7   8   9   10   11   12   13   14   15




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling