Sharedjelecevic_vinkovic.sagewsOpen in CoCalc

Linearna algebra

Zadatak 1

Zadajte simboličke matrice te izračunajte matricu C\mathbf{C} definiranu izrazom C=ABBA.\mathbf{C}=\mathbf{AB}-\mathbf{BA}. Kada bi A\mathbf A i B\mathbf B bili brojevi a ne matrice, kolika bi bila vrijednost C\mathbf C?

Matrica je pravokutna tablica brojeva. Matrica reda m x n ima m redaka i n stupaca. Zadana matrica A\mathbf{A} je reda 2x2. Vidi ovaj link, ali ne ovaj !

A = matrix(2, 2, var('a11', 'a12', 'a21', 'a22'))
show(A)
show(A*A)  # Matrice se mogu množiti pod određenim uvjetima na njihove redove (detaljnije ćete vidjeti u Matematici 1) i rezultat množenja je opet matrica. Umnožak dvije matrice A i B realiziramo koristeći operator * , isto kao i kod množenja brojeva, A*B

# Matrice istog reda se mogu i zbrajati i oduzimati korištenjem standarnih operatora + i - i rezultat ovih operacija je opet matrica

B = matrix(2, 2, var('b11', 'b12', 'b21', 'b22'))
show(B)

C = A*B - B*A
show(C)
(a11a12a21a22)\displaystyle \left(\begin{array}{rr} a_{11} & a_{12} \\ a_{21} & a_{22} \end{array}\right)
(a112+a12a21a11a12+a12a22a11a21+a21a22a12a21+a222)\displaystyle \left(\begin{array}{rr} a_{11}^{2} + a_{12} a_{21} & a_{11} a_{12} + a_{12} a_{22} \\ a_{11} a_{21} + a_{21} a_{22} & a_{12} a_{21} + a_{22}^{2} \end{array}\right)
(b11b12b21b22)\displaystyle \left(\begin{array}{rr} b_{11} & b_{12} \\ b_{21} & b_{22} \end{array}\right)
(a21b12+a12b21a12b11+a11b12a22b12+a12b22a21b11a11b21+a22b21a21b22a21b12a12b21)\displaystyle \left(\begin{array}{rr} -a_{21} b_{12} + a_{12} b_{21} & -a_{12} b_{11} + a_{11} b_{12} - a_{22} b_{12} + a_{12} b_{22} \\ a_{21} b_{11} - a_{11} b_{21} + a_{22} b_{21} - a_{21} b_{22} & a_{21} b_{12} - a_{12} b_{21} \end{array}\right)

Zadatak 2

Unesite dvije matrice, A\mathbf A i B\mathbf B, čiji matrični elementi su brojevi, koje su obje kvadratne, regularne i reda barem 3x3. Izračunajte:

  • det(A)det(A1)\det(\mathbf A)\det(\mathbf{A}^{-1}) i
  • det(AB)det(A)det(B)\det(\mathbf{A}\mathbf{B})-\det(\mathbf A)\det(\mathbf B)

Ovdje A1\mathbf{A}^{-1} označava matricu inverznu matrici A\mathbf A, a det(A)\det(\mathbf A) označava determinantu matrice A\mathbf A. Determinanta matrice je broj. Više o tome u Matematici 1.

Matrica je kvadratna ako ima jednak broj redaka i stupaca. Znači kvadratne matrice su uvijek reda m x m.

U trenutku rješavanja ovog labosa još vjerojatno ne znate za pojam regularna matrica. Bit će dovoljno da unesete neke dvije matrice A\mathbf A i B\mathbf B, takve da su im determinante različite od nule. Vidjet ćete kasnije u Matematici 1 da je to upravo jedna od karakterizacija regularnih matrica.

ex = matrix(2, 2, [1, 2, 0, 1]) # Definirali smo matricu A sa konkretnim brojevima. A je reda 2x2.
show(ex)
show(ex.det()) # Determinanta matrice A
show(ex.inverse()) # Matrica inverzna matrici A

A = matrix(3, 3, [1, 6, 3, 9, 1, 4, 0, 2, 0])
B = matrix(3, 3, [1, 5, 3, 4, 1, 2, 0, 9, 2])

show(A)
show(B)
show(A.det())
show(B.det())
show(A.det() * A.inverse().det())
show((A * B).det() - A.det() * B.det())
(1201)\displaystyle \left(\begin{array}{rr} 1 & 2 \\ 0 & 1 \end{array}\right)
1\displaystyle 1
(1201)\displaystyle \left(\begin{array}{rr} 1 & -2 \\ 0 & 1 \end{array}\right)
(163914020)\displaystyle \left(\begin{array}{rrr} 1 & 6 & 3 \\ 9 & 1 & 4 \\ 0 & 2 & 0 \end{array}\right)
(153412092)\displaystyle \left(\begin{array}{rrr} 1 & 5 & 3 \\ 4 & 1 & 2 \\ 0 & 9 & 2 \end{array}\right)
46\displaystyle 46
52\displaystyle 52
1\displaystyle 1
0\displaystyle 0

Zadatak 3

Definirajte simboličke matrice

Izračunajte detB\det \mathbf B i A1\mathbf A^{-1}.

def simbolicka_matrica(v, n):
    xevi = list(var(v + '_%d%d' %(i,j)) for i in interval(1, n) for j in interval(1, n))
    return matrix(n, xevi)

A = simbolicka_matrica('alpha', 2)

show(A)

# Da si olakšate, koristite definiranu rutinu simbolicka_matrica().

B = simbolicka_matrica('alpha', 3)
C = simbolicka_matrica('beta', 5)

show(C.det())
show(B.inverse())
(α11α12α21α22)\displaystyle \left(\begin{array}{rr} \alpha_{11} & \alpha_{12} \\ \alpha_{21} & \alpha_{22} \end{array}\right)
β15β24β33β42β51β14β25β33β42β51β15β23β34β42β51+β13β25β34β42β51+β14β23β35β42β51β13β24β35β42β51β15β24β32β43β51+β14β25β32β43β51+β15β22β34β43β51β12β25β34β43β51β14β22β35β43β51+β12β24β35β43β51+β15β23β32β44β51β13β25β32β44β51β15β22β33β44β51+β12β25β33β44β51+β13β22β35β44β51β12β23β35β44β51β14β23β32β45β51+β13β24β32β45β51+β14β22β33β45β51β12β24β33β45β51β13β22β34β45β51+β12β23β34β45β51β15β24β33β41β52+β14β25β33β41β52+β15β23β34β41β52β13β25β34β41β52β14β23β35β41β52+β13β24β35β41β52+β15β24β31β43β52β14β25β31β43β52β15β21β34β43β52+β11β25β34β43β52+β14β21β35β43β52β11β24β35β43β52β15β23β31β44β52+β13β25β31β44β52+β15β21β33β44β52β11β25β33β44β52β13β21β35β44β52+β11β23β35β44β52+β14β23β31β45β52β13β24β31β45β52β14β21β33β45β52+β11β24β33β45β52+β13β21β34β45β52β11β23β34β45β52+β15β24β32β41β53β14β25β32β41β53β15β22β34β41β53+β12β25β34β41β53+β14β22β35β41β53β12β24β35β41β53β15β24β31β42β53+β14β25β31β42β53+β15β21β34β42β53β11β25β34β42β53β14β21β35β42β53+β11β24β35β42β53+β15β22β31β44β53β12β25β31β44β53β15β21β32β44β53+β11β25β32β44β53+β12β21β35β44β53β11β22β35β44β53β14β22β31β45β53+β12β24β31β45β53+β14β21β32β45β53β11β24β32β45β53β12β21β34β45β53+β11β22β34β45β53β15β23β32β41β54+β13β25β32β41β54+β15β22β33β41β54β12β25β33β41β54β13β22β35β41β54+β12β23β35β41β54+β15β23β31β42β54β13β25β31β42β54β15β21β33β42β54+β11β25β33β42β54+β13β21β35β42β54β11β23β35β42β54β15β22β31β43β54+β12β25β31β43β54+β15β21β32β43β54β11β25β32β43β54β12β21β35β43β54+β11β22β35β43β54+β13β22β31β45β54β12β23β31β45β54β13β21β32β45β54+β11β23β32β45β54+β12β21β33β45β54β11β22β33β45β54+β14β23β32β41β55β13β24β32β41β55β14β22β33β41β55+β12β24β33β41β55+β13β22β34β41β55β12β23β34β41β55β14β23β31β42β55+β13β24β31β42β55+β14β21β33β42β55β11β24β33β42β55β13β21β34β42β55+β11β23β34β42β55+β14β22β31β43β55β12β24β31β43β55β14β21β32β43β55+β11β24β32β43β55+β12β21β34β43β55β11β22β34β43β55β13β22β31β44β55+β12β23β31β44β55+β13β21β32β44β55β11β23β32β44β55β12β21β33β44β55+β11β22β33β44β55\displaystyle \beta_{15} \beta_{24} \beta_{33} \beta_{42} \beta_{51} - \beta_{14} \beta_{25} \beta_{33} \beta_{42} \beta_{51} - \beta_{15} \beta_{23} \beta_{34} \beta_{42} \beta_{51} + \beta_{13} \beta_{25} \beta_{34} \beta_{42} \beta_{51} + \beta_{14} \beta_{23} \beta_{35} \beta_{42} \beta_{51} - \beta_{13} \beta_{24} \beta_{35} \beta_{42} \beta_{51} - \beta_{15} \beta_{24} \beta_{32} \beta_{43} \beta_{51} + \beta_{14} \beta_{25} \beta_{32} \beta_{43} \beta_{51} + \beta_{15} \beta_{22} \beta_{34} \beta_{43} \beta_{51} - \beta_{12} \beta_{25} \beta_{34} \beta_{43} \beta_{51} - \beta_{14} \beta_{22} \beta_{35} \beta_{43} \beta_{51} + \beta_{12} \beta_{24} \beta_{35} \beta_{43} \beta_{51} + \beta_{15} \beta_{23} \beta_{32} \beta_{44} \beta_{51} - \beta_{13} \beta_{25} \beta_{32} \beta_{44} \beta_{51} - \beta_{15} \beta_{22} \beta_{33} \beta_{44} \beta_{51} + \beta_{12} \beta_{25} \beta_{33} \beta_{44} \beta_{51} + \beta_{13} \beta_{22} \beta_{35} \beta_{44} \beta_{51} - \beta_{12} \beta_{23} \beta_{35} \beta_{44} \beta_{51} - \beta_{14} \beta_{23} \beta_{32} \beta_{45} \beta_{51} + \beta_{13} \beta_{24} \beta_{32} \beta_{45} \beta_{51} + \beta_{14} \beta_{22} \beta_{33} \beta_{45} \beta_{51} - \beta_{12} \beta_{24} \beta_{33} \beta_{45} \beta_{51} - \beta_{13} \beta_{22} \beta_{34} \beta_{45} \beta_{51} + \beta_{12} \beta_{23} \beta_{34} \beta_{45} \beta_{51} - \beta_{15} \beta_{24} \beta_{33} \beta_{41} \beta_{52} + \beta_{14} \beta_{25} \beta_{33} \beta_{41} \beta_{52} + \beta_{15} \beta_{23} \beta_{34} \beta_{41} \beta_{52} - \beta_{13} \beta_{25} \beta_{34} \beta_{41} \beta_{52} - \beta_{14} \beta_{23} \beta_{35} \beta_{41} \beta_{52} + \beta_{13} \beta_{24} \beta_{35} \beta_{41} \beta_{52} + \beta_{15} \beta_{24} \beta_{31} \beta_{43} \beta_{52} - \beta_{14} \beta_{25} \beta_{31} \beta_{43} \beta_{52} - \beta_{15} \beta_{21} \beta_{34} \beta_{43} \beta_{52} + \beta_{11} \beta_{25} \beta_{34} \beta_{43} \beta_{52} + \beta_{14} \beta_{21} \beta_{35} \beta_{43} \beta_{52} - \beta_{11} \beta_{24} \beta_{35} \beta_{43} \beta_{52} - \beta_{15} \beta_{23} \beta_{31} \beta_{44} \beta_{52} + \beta_{13} \beta_{25} \beta_{31} \beta_{44} \beta_{52} + \beta_{15} \beta_{21} \beta_{33} \beta_{44} \beta_{52} - \beta_{11} \beta_{25} \beta_{33} \beta_{44} \beta_{52} - \beta_{13} \beta_{21} \beta_{35} \beta_{44} \beta_{52} + \beta_{11} \beta_{23} \beta_{35} \beta_{44} \beta_{52} + \beta_{14} \beta_{23} \beta_{31} \beta_{45} \beta_{52} - \beta_{13} \beta_{24} \beta_{31} \beta_{45} \beta_{52} - \beta_{14} \beta_{21} \beta_{33} \beta_{45} \beta_{52} + \beta_{11} \beta_{24} \beta_{33} \beta_{45} \beta_{52} + \beta_{13} \beta_{21} \beta_{34} \beta_{45} \beta_{52} - \beta_{11} \beta_{23} \beta_{34} \beta_{45} \beta_{52} + \beta_{15} \beta_{24} \beta_{32} \beta_{41} \beta_{53} - \beta_{14} \beta_{25} \beta_{32} \beta_{41} \beta_{53} - \beta_{15} \beta_{22} \beta_{34} \beta_{41} \beta_{53} + \beta_{12} \beta_{25} \beta_{34} \beta_{41} \beta_{53} + \beta_{14} \beta_{22} \beta_{35} \beta_{41} \beta_{53} - \beta_{12} \beta_{24} \beta_{35} \beta_{41} \beta_{53} - \beta_{15} \beta_{24} \beta_{31} \beta_{42} \beta_{53} + \beta_{14} \beta_{25} \beta_{31} \beta_{42} \beta_{53} + \beta_{15} \beta_{21} \beta_{34} \beta_{42} \beta_{53} - \beta_{11} \beta_{25} \beta_{34} \beta_{42} \beta_{53} - \beta_{14} \beta_{21} \beta_{35} \beta_{42} \beta_{53} + \beta_{11} \beta_{24} \beta_{35} \beta_{42} \beta_{53} + \beta_{15} \beta_{22} \beta_{31} \beta_{44} \beta_{53} - \beta_{12} \beta_{25} \beta_{31} \beta_{44} \beta_{53} - \beta_{15} \beta_{21} \beta_{32} \beta_{44} \beta_{53} + \beta_{11} \beta_{25} \beta_{32} \beta_{44} \beta_{53} + \beta_{12} \beta_{21} \beta_{35} \beta_{44} \beta_{53} - \beta_{11} \beta_{22} \beta_{35} \beta_{44} \beta_{53} - \beta_{14} \beta_{22} \beta_{31} \beta_{45} \beta_{53} + \beta_{12} \beta_{24} \beta_{31} \beta_{45} \beta_{53} + \beta_{14} \beta_{21} \beta_{32} \beta_{45} \beta_{53} - \beta_{11} \beta_{24} \beta_{32} \beta_{45} \beta_{53} - \beta_{12} \beta_{21} \beta_{34} \beta_{45} \beta_{53} + \beta_{11} \beta_{22} \beta_{34} \beta_{45} \beta_{53} - \beta_{15} \beta_{23} \beta_{32} \beta_{41} \beta_{54} + \beta_{13} \beta_{25} \beta_{32} \beta_{41} \beta_{54} + \beta_{15} \beta_{22} \beta_{33} \beta_{41} \beta_{54} - \beta_{12} \beta_{25} \beta_{33} \beta_{41} \beta_{54} - \beta_{13} \beta_{22} \beta_{35} \beta_{41} \beta_{54} + \beta_{12} \beta_{23} \beta_{35} \beta_{41} \beta_{54} + \beta_{15} \beta_{23} \beta_{31} \beta_{42} \beta_{54} - \beta_{13} \beta_{25} \beta_{31} \beta_{42} \beta_{54} - \beta_{15} \beta_{21} \beta_{33} \beta_{42} \beta_{54} + \beta_{11} \beta_{25} \beta_{33} \beta_{42} \beta_{54} + \beta_{13} \beta_{21} \beta_{35} \beta_{42} \beta_{54} - \beta_{11} \beta_{23} \beta_{35} \beta_{42} \beta_{54} - \beta_{15} \beta_{22} \beta_{31} \beta_{43} \beta_{54} + \beta_{12} \beta_{25} \beta_{31} \beta_{43} \beta_{54} + \beta_{15} \beta_{21} \beta_{32} \beta_{43} \beta_{54} - \beta_{11} \beta_{25} \beta_{32} \beta_{43} \beta_{54} - \beta_{12} \beta_{21} \beta_{35} \beta_{43} \beta_{54} + \beta_{11} \beta_{22} \beta_{35} \beta_{43} \beta_{54} + \beta_{13} \beta_{22} \beta_{31} \beta_{45} \beta_{54} - \beta_{12} \beta_{23} \beta_{31} \beta_{45} \beta_{54} - \beta_{13} \beta_{21} \beta_{32} \beta_{45} \beta_{54} + \beta_{11} \beta_{23} \beta_{32} \beta_{45} \beta_{54} + \beta_{12} \beta_{21} \beta_{33} \beta_{45} \beta_{54} - \beta_{11} \beta_{22} \beta_{33} \beta_{45} \beta_{54} + \beta_{14} \beta_{23} \beta_{32} \beta_{41} \beta_{55} - \beta_{13} \beta_{24} \beta_{32} \beta_{41} \beta_{55} - \beta_{14} \beta_{22} \beta_{33} \beta_{41} \beta_{55} + \beta_{12} \beta_{24} \beta_{33} \beta_{41} \beta_{55} + \beta_{13} \beta_{22} \beta_{34} \beta_{41} \beta_{55} - \beta_{12} \beta_{23} \beta_{34} \beta_{41} \beta_{55} - \beta_{14} \beta_{23} \beta_{31} \beta_{42} \beta_{55} + \beta_{13} \beta_{24} \beta_{31} \beta_{42} \beta_{55} + \beta_{14} \beta_{21} \beta_{33} \beta_{42} \beta_{55} - \beta_{11} \beta_{24} \beta_{33} \beta_{42} \beta_{55} - \beta_{13} \beta_{21} \beta_{34} \beta_{42} \beta_{55} + \beta_{11} \beta_{23} \beta_{34} \beta_{42} \beta_{55} + \beta_{14} \beta_{22} \beta_{31} \beta_{43} \beta_{55} - \beta_{12} \beta_{24} \beta_{31} \beta_{43} \beta_{55} - \beta_{14} \beta_{21} \beta_{32} \beta_{43} \beta_{55} + \beta_{11} \beta_{24} \beta_{32} \beta_{43} \beta_{55} + \beta_{12} \beta_{21} \beta_{34} \beta_{43} \beta_{55} - \beta_{11} \beta_{22} \beta_{34} \beta_{43} \beta_{55} - \beta_{13} \beta_{22} \beta_{31} \beta_{44} \beta_{55} + \beta_{12} \beta_{23} \beta_{31} \beta_{44} \beta_{55} + \beta_{13} \beta_{21} \beta_{32} \beta_{44} \beta_{55} - \beta_{11} \beta_{23} \beta_{32} \beta_{44} \beta_{55} - \beta_{12} \beta_{21} \beta_{33} \beta_{44} \beta_{55} + \beta_{11} \beta_{22} \beta_{33} \beta_{44} \beta_{55}
((α13α11α12(α13α21α11α23)α11(α12α21α11α22))(α21(α12α31α11α32)α11(α12α21α11α22)α31α11)(α13α21α11α23)(α12α31α11α32)α12α21α11α22α13α31α11+α33+1α11α12α21α112(α12α21α11α22)(α12α31α11α32)(α13α11α12(α13α21α11α23)α11(α12α21α11α22))(α12α21α11α22)((α13α21α11α23)(α12α31α11α32)α12α21α11α22α13α31α11+α33)+α12α11(α12α21α11α22)α13α11α12(α13α21α11α23)α11(α12α21α11α22)(α13α21α11α23)(α12α31α11α32)α12α21α11α22α13α31α11+α33(α13α21α11α23)(α21(α12α31α11α32)α11(α12α21α11α22)α31α11)(α12α21α11α22)((α13α21α11α23)(α12α31α11α32)α12α21α11α22α13α31α11+α33)+α21α11(α12α21α11α22)1α12α21α11α22+(α13α21α11α23)(α12α31α11α32)(α12α21α11α22)2((α13α21α11α23)(α12α31α11α32)α12α21α11α22α13α31α11+α33)α13α21α11α23(α12α21α11α22)((α13α21α11α23)(α12α31α11α32)α12α21α11α22α13α31α11+α33)α21(α12α31α11α32)α11(α12α21α11α22)α31α11(α13α21α11α23)(α12α31α11α32)α12α21α11α22α13α31α11+α33α12α31α11α32(α12α21α11α22)((α13α21α11α23)(α12α31α11α32)α12α21α11α22α13α31α11+α33)1(α13α21α11α23)(α12α31α11α32)α12α21α11α22α13α31α11+α33)\displaystyle \left(\begin{array}{rrr} -\frac{{\left(\frac{\alpha_{13}}{\alpha_{11}} - \frac{\alpha_{12} {\left(\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}\right)}}{\alpha_{11} {\left(\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}\right)}}\right)} {\left(\frac{\alpha_{21} {\left(\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}\right)}}{\alpha_{11} {\left(\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}\right)}} - \frac{\alpha_{31}}{\alpha_{11}}\right)}}{\frac{{\left(\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}\right)} {\left(\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}\right)}}{\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}} - \frac{\alpha_{13} \alpha_{31}}{\alpha_{11}} + \alpha_{33}} + \frac{1}{\alpha_{11}} - \frac{\alpha_{12} \alpha_{21}}{\alpha_{11}^{2} {\left(\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}\right)}} & \frac{{\left(\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}\right)} {\left(\frac{\alpha_{13}}{\alpha_{11}} - \frac{\alpha_{12} {\left(\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}\right)}}{\alpha_{11} {\left(\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}\right)}}\right)}}{{\left(\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}\right)} {\left(\frac{{\left(\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}\right)} {\left(\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}\right)}}{\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}} - \frac{\alpha_{13} \alpha_{31}}{\alpha_{11}} + \alpha_{33}\right)}} + \frac{\alpha_{12}}{\alpha_{11} {\left(\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}\right)}} & -\frac{\frac{\alpha_{13}}{\alpha_{11}} - \frac{\alpha_{12} {\left(\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}\right)}}{\alpha_{11} {\left(\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}\right)}}}{\frac{{\left(\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}\right)} {\left(\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}\right)}}{\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}} - \frac{\alpha_{13} \alpha_{31}}{\alpha_{11}} + \alpha_{33}} \\ -\frac{{\left(\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}\right)} {\left(\frac{\alpha_{21} {\left(\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}\right)}}{\alpha_{11} {\left(\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}\right)}} - \frac{\alpha_{31}}{\alpha_{11}}\right)}}{{\left(\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}\right)} {\left(\frac{{\left(\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}\right)} {\left(\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}\right)}}{\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}} - \frac{\alpha_{13} \alpha_{31}}{\alpha_{11}} + \alpha_{33}\right)}} + \frac{\alpha_{21}}{\alpha_{11} {\left(\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}\right)}} & -\frac{1}{\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}} + \frac{{\left(\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}\right)} {\left(\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}\right)}}{{\left(\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}\right)}^{2} {\left(\frac{{\left(\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}\right)} {\left(\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}\right)}}{\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}} - \frac{\alpha_{13} \alpha_{31}}{\alpha_{11}} + \alpha_{33}\right)}} & -\frac{\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}}{{\left(\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}\right)} {\left(\frac{{\left(\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}\right)} {\left(\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}\right)}}{\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}} - \frac{\alpha_{13} \alpha_{31}}{\alpha_{11}} + \alpha_{33}\right)}} \\ \frac{\frac{\alpha_{21} {\left(\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}\right)}}{\alpha_{11} {\left(\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}\right)}} - \frac{\alpha_{31}}{\alpha_{11}}}{\frac{{\left(\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}\right)} {\left(\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}\right)}}{\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}} - \frac{\alpha_{13} \alpha_{31}}{\alpha_{11}} + \alpha_{33}} & -\frac{\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}}{{\left(\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}\right)} {\left(\frac{{\left(\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}\right)} {\left(\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}\right)}}{\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}} - \frac{\alpha_{13} \alpha_{31}}{\alpha_{11}} + \alpha_{33}\right)}} & \frac{1}{\frac{{\left(\frac{\alpha_{13} \alpha_{21}}{\alpha_{11}} - \alpha_{23}\right)} {\left(\frac{\alpha_{12} \alpha_{31}}{\alpha_{11}} - \alpha_{32}\right)}}{\frac{\alpha_{12} \alpha_{21}}{\alpha_{11}} - \alpha_{22}} - \frac{\alpha_{13} \alpha_{31}}{\alpha_{11}} + \alpha_{33}} \end{array}\right)

Zadatak 4

Unesite matricu

Izračunajte A2n\mathbf{A}^{2n} za n{1,2,,10}n\in\{1,2,\ldots,10\}.

### Napomena: potenciranje matrica se, kao i kod brojeva, radi pomoću operacije ^
A = matrix(2, 2, [(sqrt(2) / 2), (-sqrt(2) / 2), (sqrt(2) / 2), (sqrt(2) / 2)])

for n in range(1, 11):
    show(A ^ (2*n))
(0110)\displaystyle \left(\begin{array}{rr} 0 & -1 \\ 1 & 0 \end{array}\right)
(1001)\displaystyle \left(\begin{array}{rr} -1 & 0 \\ 0 & -1 \end{array}\right)
(0110)\displaystyle \left(\begin{array}{rr} 0 & 1 \\ -1 & 0 \end{array}\right)
(1001)\displaystyle \left(\begin{array}{rr} 1 & 0 \\ 0 & 1 \end{array}\right)
(0110)\displaystyle \left(\begin{array}{rr} 0 & -1 \\ 1 & 0 \end{array}\right)
(1001)\displaystyle \left(\begin{array}{rr} -1 & 0 \\ 0 & -1 \end{array}\right)
(0110)\displaystyle \left(\begin{array}{rr} 0 & 1 \\ -1 & 0 \end{array}\right)
(1001)\displaystyle \left(\begin{array}{rr} 1 & 0 \\ 0 & 1 \end{array}\right)
(0110)\displaystyle \left(\begin{array}{rr} 0 & -1 \\ 1 & 0 \end{array}\right)
(1001)\displaystyle \left(\begin{array}{rr} -1 & 0 \\ 0 & -1 \end{array}\right)

Zadatak 5

Unesite neku kvadratnu matricu B\mathbf B, čiji matrični elementi su brojevi, oblika 2×22\times 2. Nacrtajte vektore x=(1,0)\vec x=(1,0) i y=(0,1)\vec y=(0,1) redom u crvenoj i plavoj tamnoj boji, te vektore Bx\mathbf B\vec x i By\mathbf B\vec y u svijetlim tonovima istih boja.

x = vector([1, 0])
y = vector([0, 1])
vx = arrow((0, 0), x, color=(0.7, 0, 0)) # Vektor na crtežu reprezentiramo strelicom sa početkom u ishodištu koordinatnog sustava i vrhom u točki čije su koordinate određene vektorom. Boja je zadana u (red, green, blue) obliku, kao kombinacija osnovne tri boje. Intenzitet svake od osnovne tri boje zadan je brojem između 0 i 1.
vy = arrow((0, 0), y, color=(0, 0, 0.7))

# Primjena matrice na vektor se isto piše kao operacija množenja između matrica.

show(vx+vy, aspect_ratio=1)

B = matrix(2, 2, [1, 2, 3, 4])
vbx = arrow((0, 0), B*x, color=(1, 0, 0))
vby = arrow((0, 0), B*y, color=(0, 0, 1))

show(vbx+vby, aspect_ratio=1)

Primjer

U ovisnosti o (interaktivno zadanim) parametrima l,m[1,1]l,m\in[-1,1] nacrtajte u prostoru plohu x2+y2+lz2=m.x^2+y^2+lz^2=m.

x,y,z = var('x, y, z')
@interact
def f(l=(-1,1), m=(-1,1)):
    P = implicit_plot3d( x^2+y^2+l*z^2==m, (x,-2,2), (y,-2,2), (z,-2,2), color='black')
    show(P)

Interact: please open in CoCalc

Zadatak 6

Nacrtajte u prostoru ravnine zadane formulama 3x+2y+z=03x+2y+z=0 (žute boje) i xyz=0x-y-z=0 (zelene boje), te vektore (3,2,0)(3,2,0) i (1,1,1)(1,-1,-1), crvenom i plavom bojom.

x, y, z = var('x, y, z')

P1 = implicit_plot3d(3*x + 2*y + z == 0, (x, -2, 2), (y, -2, 2), (z, -2, 2), color='yellow')
P2 = implicit_plot3d(x - y - z == 0, (x, -2, 2), (y, -2, 2), (z, -2, 2), color='green')

v1 = arrow((0, 0, 0), vector([3, 2, 0]), color='red')
v2 = arrow((0, 0, 0), vector([1, -1, -1]), color='blue')

show(P1+P2+v1+v2, aspect_ratio=1)

3D rendering not yet implemented

Zadatak 7

Unesite neku kvadratnu matricu A\mathbf A, čiji matrični elementi su brojevi, reda 3×33\times3. Za interaktivno zadani realan broj λ[10,10]\lambda\in[-10,10] ispišite sljedeće vrijednosti:

  • AλI\mathbf A-\lambda \mathbf I,
  • det(AλI)\det(\mathbf A-\lambda \mathbf I) i
  • r(AλI)\mathop{{\mathrm{r}}}(\mathbf A-\lambda \mathbf I), gdje je r\mathrm{r} rang matrice.

Matrica I\mathbf I označava specijalnu matricu koju zovemo matrica identiteta. Rang matrice A\mathbf A je cijeli nenegativan broj. Više o rangu matrice u Matematici 1.

A = matrix(2, 2, [1, 2, 0, 0])
show(A)
show(A.det())
show(A.rank()) # Rang matrice A

#Primijetite da se matrica može množiti s realnim brojem. Rezultat je matrica istog reda
show(5*A)

B = matrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9])
I = matrix.identity(3)

@interact
def funkcija(l=(-10, 10)):
    R = B - l*I
    show(R)
    show(R.det())
    show(R.rank())
(1200)\displaystyle \left(\begin{array}{rr} 1 & 2 \\ 0 & 0 \end{array}\right)
0\displaystyle 0
1\displaystyle 1
(51000)\displaystyle \left(\begin{array}{rr} 5 & 10 \\ 0 & 0 \end{array}\right)
Interact: please open in CoCalc