CoCalc Public FilesLygciu_sistemos_1.sagews
Author: Paulius Drungilas
Views : 66
Išspręsime lygčių sistemą $\left\{\begin{array}{ll} x_{1}+x_{2}+2x_{3}+x_{4} &=7\\ 3x_{1}+4x_{2}+8x_{3}+5x_{4} &=29\\ x_{1}+3x_{2}+7x_{3}+8x_{4} &=30\\ 2x_{1}+2x_{2}+5x_{3}+6x_{4} &=23 \end{array}\right.$ Gauso metodu.
Sukuriame sistemos matricą $A$:
A = matrix(QQ, 4, 4, [[1, 1, 2, 1], [3, 4, 8, 5], [1, 3, 7, 8], [2, 2, 5, 6]])
show(A)

$\displaystyle \left(\begin{array}{rrrr} 1 & 1 & 2 & 1 \\ 3 & 4 & 8 & 5 \\ 1 & 3 & 7 & 8 \\ 2 & 2 & 5 & 6 \end{array}\right)$


latex(A)

\left(\begin{array}{rrrr} 1 & 1 & 2 & 1 \\ 3 & 4 & 8 & 5 \\ 1 & 3 & 7 & 8 \\ 2 & 2 & 5 & 6 \end{array}\right)
Dabar prie matricos prijungiame laisvųjų narių stulpelį:
laisvieji_nariai = vector(QQ, [7, 29, 30, 23])
show(laisvieji_nariai)

$\displaystyle \left(7,\,29,\,30,\,23\right)$
B = A.augment(laisvieji_nariai, subdivide = True)
show(B)

$\displaystyle \left(\begin{array}{rrrr|r} 1 & 1 & 2 & 1 & 7 \\ 3 & 4 & 8 & 5 & 29 \\ 1 & 3 & 7 & 8 & 30 \\ 2 & 2 & 5 & 6 & 23 \end{array}\right)$
Dabar matricai $B$ taikysime elementariąsias eilučių operacijas:




B.add_multiple_of_row(1,0,-3)
show(B)

$\displaystyle \left(\begin{array}{rrrr|r} 1 & 1 & 2 & 1 & 7 \\ 0 & 1 & 2 & 2 & 8 \\ 1 & 3 & 7 & 8 & 30 \\ 2 & 2 & 5 & 6 & 23 \end{array}\right)$
B.add_multiple_of_row(2,0,-1)
show(B)

$\displaystyle \left(\begin{array}{rrrr|r} 1 & 1 & 2 & 1 & 7 \\ 0 & 1 & 2 & 2 & 8 \\ 0 & 2 & 5 & 7 & 23 \\ 2 & 2 & 5 & 6 & 23 \end{array}\right)$
B.add_multiple_of_row(3,0,-2)
show(B)

$\displaystyle \left(\begin{array}{rrrr|r} 1 & 1 & 2 & 1 & 7 \\ 0 & 1 & 2 & 2 & 8 \\ 0 & 2 & 5 & 7 & 23 \\ 0 & 0 & 1 & 4 & 9 \end{array}\right)$
B.add_multiple_of_row(2,1,-2)
show(B)

$\displaystyle \left(\begin{array}{rrrr|r} 1 & 1 & 2 & 1 & 7 \\ 0 & 1 & 2 & 2 & 8 \\ 0 & 0 & 1 & 3 & 7 \\ 0 & 0 & 1 & 4 & 9 \end{array}\right)$
B.add_multiple_of_row(3,2,-1)
show(B)

$\displaystyle \left(\begin{array}{rrrr|r} 1 & 1 & 2 & 1 & 7 \\ 0 & 1 & 2 & 2 & 8 \\ 0 & 0 & 1 & 3 & 7 \\ 0 & 0 & 0 & 1 & 2 \end{array}\right)$
B.add_multiple_of_row(2,3,-3)
show(B)

$\displaystyle \left(\begin{array}{rrrr|r} 1 & 1 & 2 & 1 & 7 \\ 0 & 1 & 2 & 2 & 8 \\ 0 & 0 & 1 & 0 & 1 \\ 0 & 0 & 0 & 1 & 2 \end{array}\right)$
B.add_multiple_of_row(1,3,-2)
show(B)

$\displaystyle \left(\begin{array}{rrrr|r} 1 & 1 & 2 & 1 & 7 \\ 0 & 1 & 2 & 0 & 4 \\ 0 & 0 & 1 & 3 & 7 \\ 0 & 0 & 0 & 1 & 2 \end{array}\right)$
B.add_multiple_of_row(0,3,-1)
show(B)

$\displaystyle \left(\begin{array}{rrrr|r} 1 & 1 & 2 & 0 & 5 \\ 0 & 1 & 2 & 0 & 4 \\ 0 & 0 & 1 & 0 & 1 \\ 0 & 0 & 0 & 1 & 2 \end{array}\right)$
B.add_multiple_of_row(1,2,-2)
show(B)

$\displaystyle \left(\begin{array}{rrrr|r} 1 & 1 & 2 & 0 & 5 \\ 0 & 1 & 0 & 0 & 2 \\ 0 & 0 & 1 & 0 & 1 \\ 0 & 0 & 0 & 1 & 2 \end{array}\right)$
B.add_multiple_of_row(0,2,-2)
show(B)

$\displaystyle \left(\begin{array}{rrrr|r} 1 & 1 & 0 & 0 & 3 \\ 0 & 1 & 0 & 0 & 2 \\ 0 & 0 & 1 & 0 & 1 \\ 0 & 0 & 0 & 1 & 2 \end{array}\right)$
B.add_multiple_of_row(0,1,-1)
show(B)

$\displaystyle \left(\begin{array}{rrrr|r} 1 & 0 & 0 & 0 & 1 \\ 0 & 1 & 0 & 0 & 2 \\ 0 & 0 & 1 & 0 & 1 \\ 0 & 0 & 0 & 1 & 2 \end{array}\right)$
Taigi sistemos sprendinys yra $x_1 = 1,\; x_2 = 2,\; x_3 = 1,\; x_4 = 2.$
Šią lygčių sistemą galima buvo spręsti kitu būdu. Lygčių sistema ekvivalenti tokiai matricų lygčiai: $\left(\begin{array}{rrrr} 1 & 1 & 2 & 1 \\ 3 & 4 & 8 & 5 \\ 1 & 3 & 7 & 8 \\ 2 & 2 & 5 & 6 \end{array}\right) \left(\begin{array}{r} x_1 \\ x_2 \\ x_3 \\ x_4 \end{array}\right) = \left(\begin{array}{r} 7 \\ 29 \\ 30 \\ 23 \end{array}\right)$
kintamieji = vector(QQ, [7, 29, 30, 23])
show(laisvieji_nariai)
︠92143d02-7c7d-4e3e-9861-52531d939d8e︠