|
Chiziqli tenglamalar sistemasini Gauss usuli yordamida yechish algoritmi va dasturi
|
bet | 2/2 | Sana | 12.10.2024 | Hajmi | 494,99 Kb. | | #274793 |
Chiziqli tenglamalar sistemasini Gauss usuli yordamida yechish algoritmi va dasturi
1-misol.
Gauss usuli bilan quyidagi sistema yechilsin.
(8) tenglamadan x1 ni topamiz
2 x1 −3 2 x+ 2 x3 − 4 x4 = 5,
2 x1 = 5 + 3 x2 − 2 x3 + 4 x4 , (12) x1 = 52 + 32 x2 − x3 + 2 x4 ,
(12) tenglamani (9) tenglamadagi x1 ni o‘rniga qo‘yamiz va uni ixchamlaymiz.
3 x1 + x2 − 2 x3 − 2 x4 = 4,
(12) tenglamani (10) tenglamadagi x1 ni o‘rniga qo‘yamiz va uni ixchamlaymiz.
4 x1 + 2 x2 −3 x3 + x4 = 2,
tenglamani (11) tenglamadagi x1 ni o‘rniga qo‘yamiz va uni ixchamlaymiz.
x1 + x2 + x3 + x4 = 2,
+ 32 x2 − x3 + 2 x4 + x2 + x3 + x4 = 2,
5+ 3 x2 − 2 x3 + 4 x4 + 2 x2 + 2 x3 + 2 x4 = 4,
5 x2 + 6 x4 =−1.
Yuqoridagilardan quyidagi yangi tenglamalar sistemasini hosil qilamiz
tenglamadan x2 ni topamiz
Algoritmi:
Dasturi:
a x a x11 1 + 12 2
a x a x21 1 + 22 2
......
a x a xn1 1 + n2 2 + +... a x1n n =b1
+ +... a x2n n =b2
+ +... a xnn n =bn
Program Gauss1; label 1,2,3,4,5; var a:array[1..10, 1..10] of real; b,x:array[1..10] of real; c,s:real; i,j,k,n:integer; begin readln(n); for i:=1 to n do begin for j:=1 to n do read(a[i,j]); readln(b[i]); end; k:=1; 3: i:=k+1; 2: c:=a[i,k]/a[k,k]; a[i,k]:=0; j:=k+1; 1: a[i,j]:=a[i,j]-c*a[k,j]; if j1 then begin i:=i-1; goto 5 end;
for i:=1 to n do writeln(x[i]:4:2); end.
a x a x11 1 + 12 2 + +... a x1n n =a1 1n+
a x a x21 1 + 22 2
......
a x a xn1 1 + n2 2
|
+ +... a x2n n + +... a xnn n
|
=a2 1n+
=ann+1
|
program Gauss; var a:array[1..10, 1..10] of real; x:array[1..10] of real; c,s,d:real; i,j,k,n,l,p:integer;
begin readln(n); for i:=1 to n do for j:=1 to n+1 do readln(a[i,j]); for k:=1 to n do begin
l:=k; while a[k,k]=0 do begin
if a[l+1,k]=0 then else begin for p:=k to n+1 do7 begin d:=a[k,p]; a[k,p]:=a[l+1,p]; a[l+1,p]:=d; end; break; end; l:=l+1; end; for i:=k to n-1 do begin c:=a[i+1,k]; for j:=k to n+1 do
a[i+1,j]:=(a[k,j]/a[k,k])*c-a[i+1,j]; end; end; x[n]:=a[n,n+1]/a[n,n]; for k:=n-1 downto 1 do begin s:=0; for i:=k+1 to n do s:=s+a[k,i]*x[i]; x[k]:=(a[k,n+1]-s)/a[k,k] end; for i:=1 to n do writeln(x[i]:4:2); end.
2-masala. Quyidagi chiziqli tenglamalar sistemasini yeching:
3x x1 − +2 5x3 + =x4 7 2x1 +5x2 −3x3 =−1
2x1 −4x3 +3x4 =6
−
6x1 +4x2 −3x3 −2x4 =3
Bajarish. 1-masaladagidek, tenglamalar sistemasini AX =B ko`rinishda yozib olamiz. Bu yerda A – noma`lumlar koeffisentlardan tashkil topgan matritsa, B– ozod hadlardan tashkil topgan ustun (vektor), X– noma`lumlar ustuni (vektori).
3 -1 5 1
A=-22 5 -3 0 -4 03, B=7−1, X = xx12
6 4 -3 -2
Demak, X =A−1B .
A matritsani, ya`ni noma`lumlar koeffisentlarini A1:D4 maydonga, B vektorni, ya`ni ozod hadlarni F1:F4 maydonga kiritamiz. X vektor uchun H1:H4 maydonni belgilab =МУМНОЖ(МОБР(A1:D4);F1:F4) formulani kiritamiz va Ctrl+Shift+Enter tugmalarini birgalikda bosamiz. Natijada H1:H4 maydonda izlanayotgan noma`lumlar hosil bo`ladi:
FOYDALANILGAN ADABIYOTLAR RO`YXATI
Isroilov M. «Hisoblash metodlari», T., "O`zbekiston", 2003
Shoxamidov Sh.Sh. «Amaliy matematika unsurlari», T., "O`zbekiston", 1997
Boyzoqov A., Qayumov Sh. «Hisoblash matematikasi asoslari», O`quv qo`llanma. Toshkent 2000.
Abduqodirov A.A. «Hisoblash matematikasi va programmalash», Toshkent. "O`qituvchi" 1989.
Vorob`eva G.N. i dr. «Praktikum po vichislitel’noy matematike» M. VSh. 1990.
Abduhamidov A., Xudoynazarov S. «Hisoblash usullaridan mashqlar va laboratoriya ishlari», T.1995.
Siddiqov A. «Sonli usullar va programmalashtirish», O`quv qo`llanma. T.2001.
Internet ma`lumotlarini olish mumkin bo`lgan saytlar:
|
| |