Macierze

Wskazówka

Binder <- interaktywna sesja notebooka

from random import choice

from IPython.display import display, Markdown, Latex

import generator_zadan.generatory as gz

print(gz.__version__)
0.2.11
ile_zadan_przykladowych = 10

Wyznacznik

zadanie = gz.wyznacznik(wymiar=choice([4,5,6]))
zadanie
('Obliczyć wyznacznik macierzy A\n\t\\[\n\t\t\\textnormal{A=} \\left[\\begin{matrix}2 & 0 & -2 & 3 & 0 & -2\\\\3 & -2 & -1 & 3 & -1 & 3\\\\0 & 1 & 0 & 1 & 2 & 3\\\\2 & 1 & -2 & 3 & 2 & 3\\\\1 & 2 & -2 & 3 & 3 & 0\\\\-1 & 3 & 1 & 2 & 0 & 0\\end{matrix}\\right]\n\t\\]',
 '$\\det(A)= -6$')
Hide code cell source
print("\033[34m** Zadanie **" + '*' * 81 + '\033[0m')
print(zadanie[0])
print("\033[34m*\033[0m" * 95)
print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
print(zadanie[1])
print("\033[32m*\033[0m" * 95)
** Zadanie ***********************************************************************************
Obliczyć wyznacznik macierzy A
	\[
		\textnormal{A=} \left[\begin{matrix}2 & 0 & -2 & 3 & 0 & -2\\3 & -2 & -1 & 3 & -1 & 3\\0 & 1 & 0 & 1 & 2 & 3\\2 & 1 & -2 & 3 & 2 & 3\\1 & 2 & -2 & 3 & 3 & 0\\-1 & 3 & 1 & 2 & 0 & 0\end{matrix}\right]
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$\det(A)= -6$
***********************************************************************************************
Hide code cell source
for i in range(1, ile_zadan_przykladowych + 1):
    zadanie = gz.wyznacznik(wymiar=choice([4,5,6]))
    print(f"\033[34m** Zadanie {i} **" + '*' * 80 + '\033[0m')
    display(Markdown(zadanie[0][:30].replace('A', '*A*')))
    display(Latex(zadanie[0][30:]))
    print("\033[34m*\033[0m" * 95)
    print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
    display(Latex(zadanie[1].replace("$", "$$")))
    print("\033[32m*\033[0m" * 95)
** Zadanie 1 **********************************************************************************

Obliczyć wyznacznik macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-1 & 3 & 2 & -1 & -1\\1 & 2 & 0 & -2 & -1\\3 & 2 & 2 & 0 & 1\\1 & 0 & 1 & -1 & 1\\0 & 3 & 2 & 1 & -1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det(A)= -12\]
***********************************************************************************************
** Zadanie 2 **********************************************************************************

Obliczyć wyznacznik macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}3 & 1 & -1 & 0\\-1 & 1 & 0 & 0\\-2 & 2 & 1 & -1\\-1 & 0 & -2 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det(A)= -5\]
***********************************************************************************************
** Zadanie 3 **********************************************************************************

Obliczyć wyznacznik macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}2 & 0 & 3 & 1 & -2\\1 & 1 & 2 & 0 & 0\\-2 & -1 & -2 & 0 & 3\\0 & 0 & 0 & -2 & 1\\1 & 2 & 1 & -1 & 0\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det(A)= -6\]
***********************************************************************************************
** Zadanie 4 **********************************************************************************

Obliczyć wyznacznik macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-1 & 2 & 2 & 3 & -2 & -1\\3 & -1 & 2 & 2 & -2 & 0\\3 & -1 & -1 & -2 & 1 & 2\\0 & 2 & -1 & 0 & 0 & 3\\-2 & 0 & 3 & -1 & -1 & 2\\1 & 1 & 0 & 2 & -1 & 0\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det(A)= -1\]
***********************************************************************************************
** Zadanie 5 **********************************************************************************

Obliczyć wyznacznik macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-1 & -1 & -2 & 2 & 3 & 0\\3 & 1 & 1 & 0 & 1 & 1\\3 & -1 & -2 & 3 & 3 & -1\\3 & 0 & 3 & -1 & 1 & 0\\1 & 1 & 1 & 1 & 3 & 1\\3 & -1 & 0 & 1 & 0 & -2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det(A)= 5\]
***********************************************************************************************
** Zadanie 6 **********************************************************************************

Obliczyć wyznacznik macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}1 & 2 & 1 & 3 & -2 & -2\\3 & -2 & 1 & -2 & 1 & 0\\-2 & 3 & 3 & 1 & 1 & 0\\-1 & 2 & 3 & 3 & 2 & -1\\-2 & -1 & 1 & -1 & 1 & 1\\2 & 2 & -2 & 3 & 3 & -1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det(A)= -4\]
***********************************************************************************************
** Zadanie 7 **********************************************************************************

Obliczyć wyznacznik macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}3 & 0 & -1 & 3\\-1 & 3 & 2 & 1\\1 & -1 & -1 & -2\\3 & 1 & -1 & 3\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det(A)= -11\]
***********************************************************************************************
** Zadanie 8 **********************************************************************************

Obliczyć wyznacznik macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}3 & -1 & -2 & 2\\1 & 2 & 0 & 1\\2 & 3 & 0 & 2\\3 & -1 & 1 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det(A)= -5\]
***********************************************************************************************
** Zadanie 9 **********************************************************************************

Obliczyć wyznacznik macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}2 & 3 & -1 & -2 & 0 & 3\\0 & 0 & 2 & 2 & -2 & 2\\-1 & -2 & 3 & 2 & -2 & 0\\1 & -1 & 2 & -1 & 0 & 3\\-1 & -2 & 1 & 1 & 1 & 3\\2 & 0 & 2 & 1 & -1 & 3\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det(A)= 0\]
***********************************************************************************************
** Zadanie 10 **********************************************************************************

Obliczyć wyznacznik macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}0 & 0 & -1 & 0 & 0\\-1 & 0 & -1 & 1 & -2\\-2 & 1 & 1 & 1 & 0\\1 & 0 & -2 & 3 & 1\\2 & 0 & -1 & 2 & 3\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det(A)= 0\]
***********************************************************************************************

Równanie macierzowe

zadanie = gz.rownanie_macierzowe()
zadanie
('Rozwiązać równanie:\n\t\\[\n\t\t\\left[\\begin{matrix}1 & 1 & 2 & 0 & 0\\\\1 & 0 & 2 & 1 & 0\\end{matrix}\\right]\\cdot \n\t\t\\left[\\begin{matrix}-1 & 1 & 0 & -2 & 1\\\\0 & -1 & 0 & -1 & -1\\end{matrix}\\right]^T + \n\t\t4X=\n\t\tX \\cdot \\left[\\begin{matrix}-1 & 1\\\\0 & -1\\\\-1 & -1\\\\0 & -1\\\\2 & -1\\end{matrix}\\right]^T \\cdot\n\t\t\\left[\\begin{matrix}-2 & -2\\\\-2 & -2\\\\0 & -1\\\\-2 & 0\\\\1 & 0\\end{matrix}\\right] \n\t\\]',
 '$ \\left[\\begin{matrix}0 & -1\\\\-3 & -1\\end{matrix}\\right] + \n\t4X=\n\tX \\cdot \\left[\\begin{matrix}4 & 3\\\\1 & 1\\end{matrix}\\right] , \\quad \n\t\\left[\\begin{matrix}0 & -1\\\\-3 & -1\\end{matrix}\\right] = \n\tX \\cdot \\left[\\begin{matrix}0 & 3\\\\1 & -3\\end{matrix}\\right] $ \\\\ \n\t$X=\\frac{1}{-3}\\left[\\begin{matrix}1 & 0\\\\10 & 9\\end{matrix}\\right].$')
Hide code cell source
print("\033[34m** Zadanie **" + '*' * 81 + '\033[0m')
print(zadanie[0])
print("\033[34m*\033[0m" * 95)
print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
print(zadanie[1])
print("\033[32m*\033[0m" * 95)
** Zadanie ***********************************************************************************
Rozwiązać równanie:
	\[
		\left[\begin{matrix}1 & 1 & 2 & 0 & 0\\1 & 0 & 2 & 1 & 0\end{matrix}\right]\cdot 
		\left[\begin{matrix}-1 & 1 & 0 & -2 & 1\\0 & -1 & 0 & -1 & -1\end{matrix}\right]^T + 
		4X=
		X \cdot \left[\begin{matrix}-1 & 1\\0 & -1\\-1 & -1\\0 & -1\\2 & -1\end{matrix}\right]^T \cdot
		\left[\begin{matrix}-2 & -2\\-2 & -2\\0 & -1\\-2 & 0\\1 & 0\end{matrix}\right] 
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$ \left[\begin{matrix}0 & -1\\-3 & -1\end{matrix}\right] + 
	4X=
	X \cdot \left[\begin{matrix}4 & 3\\1 & 1\end{matrix}\right] , \quad 
	\left[\begin{matrix}0 & -1\\-3 & -1\end{matrix}\right] = 
	X \cdot \left[\begin{matrix}0 & 3\\1 & -3\end{matrix}\right] $ \\ 
	$X=\frac{1}{-3}\left[\begin{matrix}1 & 0\\10 & 9\end{matrix}\right].$
***********************************************************************************************
Hide code cell source
for i in range(1, ile_zadan_przykladowych + 1):
    zadanie = gz.rownanie_macierzowe()
    print(f"\033[34m** Zadanie {i} **" + '*' * 80 + '\033[0m')
    display(Markdown(zadanie[0].split(':')[0]))
    display(Latex(zadanie[0].split(':')[1]))
    print("\033[34m*\033[0m" * 95)
    print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
    display(Latex(zadanie[1].replace('$ \\\\ \n\t$', ',\\quad ').replace('$', '$$')))
    print("\033[32m*\033[0m" * 95)
** Zadanie 1 **********************************************************************************

Rozwiązać równanie

\[\begin{split} \left[\begin{matrix}0 & 0 & 0 & 0 & -1\\1 & 2 & 1 & 0 & -1\end{matrix}\right]\cdot \left[\begin{matrix}-1 & -1 & -1 & -1 & 1\\0 & 0 & -2 & 1 & 1\end{matrix}\right]^T + 3X= X \cdot \left[\begin{matrix}-1 & -1\\0 & -1\\2 & -1\\0 & 0\\0 & 1\end{matrix}\right]^T \cdot \left[\begin{matrix}1 & -2\\-2 & -1\\1 & 0\\-2 & 1\\-2 & 0\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split} \left[\begin{matrix}-1 & -1\\-5 & -3\end{matrix}\right] + 3X= X \cdot \left[\begin{matrix}1 & 2\\-2 & 3\end{matrix}\right] , \quad \left[\begin{matrix}-1 & -1\\-5 & -3\end{matrix}\right] = X \cdot \left[\begin{matrix}-2 & 2\\-2 & 0\end{matrix}\right] ,\quad X=\frac{1}{4}\left[\begin{matrix}-2 & 4\\-6 & 16\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 2 **********************************************************************************

Rozwiązać równanie

\[\begin{split} \left[\begin{matrix}0 & 2 & 0 & 0 & 1\\0 & 2 & -1 & 2 & 1\end{matrix}\right]\cdot \left[\begin{matrix}-2 & -2 & 0 & -1 & -1\\-1 & -1 & -2 & -2 & -1\end{matrix}\right]^T + 2X= X \cdot \left[\begin{matrix}1 & 2\\1 & -1\\1 & 0\\0 & 2\\1 & -1\end{matrix}\right]^T \cdot \left[\begin{matrix}1 & 0\\-1 & 0\\0 & 0\\0 & 1\\-2 & -2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split} \left[\begin{matrix}-5 & -3\\-7 & -5\end{matrix}\right] + 2X= X \cdot \left[\begin{matrix}-2 & -2\\5 & 4\end{matrix}\right] , \quad \left[\begin{matrix}-5 & -3\\-7 & -5\end{matrix}\right] = X \cdot \left[\begin{matrix}-4 & -2\\5 & 2\end{matrix}\right] ,\quad X=\frac{1}{2}\left[\begin{matrix}5 & 2\\11 & 6\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 3 **********************************************************************************

Rozwiązać równanie

\[\begin{split} \left[\begin{matrix}2 & 2 & 2 & 2 & 1\\1 & 2 & 2 & 2 & 2\end{matrix}\right]\cdot \left[\begin{matrix}0 & 1 & -1 & 1 & 0\\1 & -2 & 0 & 1 & 0\end{matrix}\right]^T + 2X= X \cdot \left[\begin{matrix}0 & 0\\0 & 0\\0 & 1\\1 & 1\\-1 & 1\end{matrix}\right]^T \cdot \left[\begin{matrix}-1 & 1\\1 & -1\\-1 & -2\\-2 & -1\\-1 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split} \left[\begin{matrix}2 & 0\\2 & -1\end{matrix}\right] + 2X= X \cdot \left[\begin{matrix}-1 & -2\\-4 & -2\end{matrix}\right] , \quad \left[\begin{matrix}2 & 0\\2 & -1\end{matrix}\right] = X \cdot \left[\begin{matrix}-3 & -2\\-4 & -4\end{matrix}\right] ,\quad X=\frac{1}{4}\left[\begin{matrix}-8 & 4\\-12 & 7\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 4 **********************************************************************************

Rozwiązać równanie

\[\begin{split} \left[\begin{matrix}-1 & 1 & 1 & 1 & 0\\1 & -1 & 2 & 0 & 1\end{matrix}\right]\cdot \left[\begin{matrix}1 & -2 & 0 & 1 & 0\\0 & -2 & 1 & -2 & -2\end{matrix}\right]^T + 4X= X \cdot \left[\begin{matrix}2 & 2\\-1 & 0\\-1 & 1\\0 & 0\\0 & 0\end{matrix}\right]^T \cdot \left[\begin{matrix}1 & 1\\1 & -1\\-2 & -2\\-1 & -1\\1 & -2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split} \left[\begin{matrix}-2 & -3\\3 & 2\end{matrix}\right] + 4X= X \cdot \left[\begin{matrix}3 & 5\\0 & 0\end{matrix}\right] , \quad \left[\begin{matrix}-2 & -3\\3 & 2\end{matrix}\right] = X \cdot \left[\begin{matrix}-1 & 5\\0 & -4\end{matrix}\right] ,\quad X=\frac{1}{4}\left[\begin{matrix}8 & 13\\-12 & -17\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 5 **********************************************************************************

Rozwiązać równanie

\[\begin{split} \left[\begin{matrix}-1 & 0 & 0 & -1 & 0\\-1 & -1 & -1 & 0 & 0\end{matrix}\right]\cdot \left[\begin{matrix}-1 & -2 & 1 & -1 & -2\\1 & -1 & -1 & -1 & 1\end{matrix}\right]^T + 3X= X \cdot \left[\begin{matrix}-1 & -1\\-1 & 1\\0 & 2\\-1 & -1\\0 & 0\end{matrix}\right]^T \cdot \left[\begin{matrix}0 & -2\\1 & -1\\0 & -2\\-2 & 0\\0 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split} \left[\begin{matrix}2 & 0\\2 & 1\end{matrix}\right] + 3X= X \cdot \left[\begin{matrix}1 & 3\\3 & -3\end{matrix}\right] , \quad \left[\begin{matrix}2 & 0\\2 & 1\end{matrix}\right] = X \cdot \left[\begin{matrix}-2 & 3\\3 & -6\end{matrix}\right] ,\quad X=\frac{1}{3}\left[\begin{matrix}-12 & -6\\-15 & -8\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 6 **********************************************************************************

Rozwiązać równanie

\[\begin{split} \left[\begin{matrix}2 & 2 & 2 & 1 & 2\\2 & 2 & 2 & 0 & 1\end{matrix}\right]\cdot \left[\begin{matrix}0 & -2 & 1 & 1 & -2\\-2 & -1 & 0 & -2 & 0\end{matrix}\right]^T + 3X= \left[\begin{matrix}0 & 1\\0 & -1\\0 & 0\\-1 & 1\\1 & 1\end{matrix}\right]^T \cdot \left[\begin{matrix}-2 & 0\\-1 & 1\\-2 & -2\\-2 & 1\\-1 & 0\end{matrix}\right] \cdot X \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split} \left[\begin{matrix}-5 & -8\\-4 & -6\end{matrix}\right] + 3X= \left[\begin{matrix}1 & -1\\-4 & 0\end{matrix}\right] \cdot X, \quad \left[\begin{matrix}-5 & -8\\-4 & -6\end{matrix}\right] = \left[\begin{matrix}-2 & -1\\-4 & -3\end{matrix}\right] \cdot X ,\quad X=\frac{1}{2}\left[\begin{matrix}11 & 18\\-12 & -20\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 7 **********************************************************************************

Rozwiązać równanie

\[\begin{split} \left[\begin{matrix}-1 & -1 & 2 & -1 & 0\\-1 & 0 & 1 & 2 & 1\end{matrix}\right]\cdot \left[\begin{matrix}1 & -2 & -1 & 1 & -2\\-1 & 1 & -2 & -2 & 0\end{matrix}\right]^T + 3X= \left[\begin{matrix}2 & 0\\2 & 1\\1 & 1\\-1 & -1\\2 & 0\end{matrix}\right]^T \cdot \left[\begin{matrix}-2 & -2\\-2 & -2\\-2 & 1\\-1 & -2\\-2 & -2\end{matrix}\right] \cdot X \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split} \left[\begin{matrix}-2 & -2\\-2 & -5\end{matrix}\right] + 3X= \left[\begin{matrix}-13 & -9\\-3 & 1\end{matrix}\right] \cdot X, \quad \left[\begin{matrix}-2 & -2\\-2 & -5\end{matrix}\right] = \left[\begin{matrix}-16 & -9\\-3 & -2\end{matrix}\right] \cdot X ,\quad X=\frac{1}{5}\left[\begin{matrix}-14 & -41\\26 & 74\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 8 **********************************************************************************

Rozwiązać równanie

\[\begin{split} \left[\begin{matrix}2 & 0 & 1 & 2 & 1\\1 & 2 & 1 & 0 & 0\end{matrix}\right]\cdot \left[\begin{matrix}-2 & 0 & 0 & 1 & -2\\-2 & -1 & 1 & 1 & -2\end{matrix}\right]^T + 3X= \left[\begin{matrix}-1 & 0\\-1 & 0\\1 & 1\\2 & 2\\1 & -1\end{matrix}\right]^T \cdot \left[\begin{matrix}-1 & 1\\1 & -1\\1 & 0\\0 & 1\\-2 & -1\end{matrix}\right] \cdot X \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split} \left[\begin{matrix}-4 & -3\\-2 & -3\end{matrix}\right] + 3X= \left[\begin{matrix}-1 & 1\\3 & 3\end{matrix}\right] \cdot X, \quad \left[\begin{matrix}-4 & -3\\-2 & -3\end{matrix}\right] = \left[\begin{matrix}-4 & 1\\3 & 0\end{matrix}\right] \cdot X ,\quad X=\frac{1}{-3}\left[\begin{matrix}2 & 3\\20 & 21\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 9 **********************************************************************************

Rozwiązać równanie

\[\begin{split} \left[\begin{matrix}2 & 0 & -1 & -1 & 0\\1 & 0 & 1 & 0 & 1\end{matrix}\right]\cdot \left[\begin{matrix}-1 & -2 & -2 & -1 & 1\\0 & -1 & 1 & 1 & 1\end{matrix}\right]^T + 2X= X \cdot \left[\begin{matrix}2 & 1\\2 & -1\\2 & 1\\1 & 0\\2 & 0\end{matrix}\right]^T \cdot \left[\begin{matrix}1 & 1\\0 & 0\\-1 & -2\\1 & 1\\0 & -2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split} \left[\begin{matrix}1 & -2\\-2 & 2\end{matrix}\right] + 2X= X \cdot \left[\begin{matrix}1 & -5\\0 & -1\end{matrix}\right] , \quad \left[\begin{matrix}1 & -2\\-2 & 2\end{matrix}\right] = X \cdot \left[\begin{matrix}-1 & -5\\0 & -3\end{matrix}\right] ,\quad X=\frac{1}{3}\left[\begin{matrix}-3 & 7\\6 & -12\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 10 **********************************************************************************

Rozwiązać równanie

\[\begin{split} \left[\begin{matrix}1 & 2 & 2 & 1 & -1\\0 & 2 & 0 & -1 & 0\end{matrix}\right]\cdot \left[\begin{matrix}-2 & -2 & 1 & -2 & -2\\-1 & -1 & -1 & 1 & 1\end{matrix}\right]^T + 3X= \left[\begin{matrix}1 & -1\\2 & 2\\2 & 0\\0 & 1\\0 & 2\end{matrix}\right]^T \cdot \left[\begin{matrix}-1 & 1\\1 & 1\\-2 & 1\\0 & -2\\0 & 1\end{matrix}\right] \cdot X \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split} \left[\begin{matrix}-4 & -5\\-2 & -3\end{matrix}\right] + 3X= \left[\begin{matrix}-3 & 5\\3 & 1\end{matrix}\right] \cdot X, \quad \left[\begin{matrix}-4 & -5\\-2 & -3\end{matrix}\right] = \left[\begin{matrix}-6 & 5\\3 & -2\end{matrix}\right] \cdot X ,\quad X=\frac{1}{-3}\left[\begin{matrix}18 & 25\\24 & 33\end{matrix}\right].\end{split}\]
***********************************************************************************************

Wyznacznik z parametrem

zadanie = gz.wyznacznik_parametr(wymiar=choice([2, 3, 4]), gotowiec=True)
zadanie
('Dla jakich rzeczywistych wartości parametru $x$ wyznacznik macierzy $A$ jest różny od zera?\n\t\\[\n\t\t\\textnormal{A=}\n\t\t\\left[\\begin{matrix}3 & x - 1 & x - 2\\\\x - 4 & x - 3 & 0\\\\-4 & -4 & -2\\end{matrix}\\right]\n\t\\]',
 '$\\det A=2 x^{2} - 12 x + 18 \\neq 0, \\quad x\\neq 3, \\ $')
Hide code cell source
print("\033[34m** Zadanie **" + '*' * 81 + '\033[0m')
print(zadanie[0])
print("\033[34m*\033[0m" * 95)
print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
print(zadanie[1])
print("\033[32m*\033[0m" * 95)
** Zadanie ***********************************************************************************
Dla jakich rzeczywistych wartości parametru $x$ wyznacznik macierzy $A$ jest różny od zera?
	\[
		\textnormal{A=}
		\left[\begin{matrix}3 & x - 1 & x - 2\\x - 4 & x - 3 & 0\\-4 & -4 & -2\end{matrix}\right]
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$\det A=2 x^{2} - 12 x + 18 \neq 0, \quad x\neq 3, \ $
***********************************************************************************************
Hide code cell source
for i in range(1, ile_zadan_przykladowych + 1):
    zadanie = gz.wyznacznik_parametr(wymiar=choice([2, 3, 4]), gotowiec=True)
    print(f"\033[34m** Zadanie {i} **" + '*' * 80 + '\033[0m')
    display(Markdown(zadanie[0][:91].replace('\\ ', ' ').replace('$', '*')))
    display(Latex(zadanie[0][91:]))
    print("\033[34m*\033[0m" * 95)
    print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
    display(Latex(zadanie[1].replace('$ \\\\ \n\t$', ',\\quad ').replace('$', '$$')))
    print("\033[32m*\033[0m" * 95)
** Zadanie 1 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x wyznacznik macierzy A jest różny od zera?

\[\begin{split} \textnormal{A=} \left[\begin{matrix}1 & -2 & 1\\x - 3 & 2 & 2 x - 1\\-3 & x - 2 & -3\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- x^{2} + 6 x + 16 \neq 0, \quad x\neq -2, \ x\neq 8, \ \]
***********************************************************************************************
** Zadanie 2 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x wyznacznik macierzy A jest różny od zera?

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-1 & 1 & 0 & 0\\3 & x - 1 & 2 & 1\\x - 4 & -2 & 2 x - 2 & -3\\1 & 2 & 4 & x + 4\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- 2 x^{3} - 8 x^{2} - 18 x - 20 \neq 0, \quad x\neq -2, \ \]
***********************************************************************************************
** Zadanie 3 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x wyznacznik macierzy A jest różny od zera?

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-1 & x - 4 & 1 & 0\\x + 1 & x + 4 & 1 & 2\\-1 & x - 2 & 3 & x + 2\\-2 & -4 & 2 & 0\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=2 x^{3} + 4 x^{2} - 16 x \neq 0, \quad x\neq -4, \ x\neq 0, \ x\neq 2, \ \]
***********************************************************************************************
** Zadanie 4 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x wyznacznik macierzy A jest różny od zera?

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-1 & -4 & -4\\x + 3 & x + 2 & -2\\0 & x - 2 & x - 4\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- x^{2} - 8 x - 12 \neq 0, \quad x\neq -6, \ x\neq -2, \ \]
***********************************************************************************************
** Zadanie 5 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x wyznacznik macierzy A jest różny od zera?

\[\begin{split} \textnormal{A=} \left[\begin{matrix}x - 1 & -3\\-2 & 2 x + 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=2 x^{2} - 8 \neq 0, \quad x\neq -2, \ x\neq 2, \ \]
***********************************************************************************************
** Zadanie 6 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x wyznacznik macierzy A jest różny od zera?

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-2 & -4 & 1 & x\\x + 1 & 2 & -3 & 3\\-1 & 3 & -1 & 1\\x - 4 & -1 & x - 2 & x + 4\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- 3 x^{3} - 10 x^{2} - 15 x - 8 \neq 0, \quad x\neq -1, \ \]
***********************************************************************************************
** Zadanie 7 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x wyznacznik macierzy A jest różny od zera?

\[\begin{split} \textnormal{A=} \left[\begin{matrix}x - 3 & x - 1\\x - 3 & -1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- x^{2} + 3 x \neq 0, \quad x\neq 0, \ x\neq 3, \ \]
***********************************************************************************************
** Zadanie 8 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x wyznacznik macierzy A jest różny od zera?

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-4 & x + 3\\x + 3 & x + 3\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- x^{2} - 10 x - 21 \neq 0, \quad x\neq -7, \ x\neq -3, \ \]
***********************************************************************************************
** Zadanie 9 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x wyznacznik macierzy A jest różny od zera?

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-4 & -3 & 2 x + 4\\x - 4 & 4 & -3\\-2 & -2 & x + 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- x^{2} - x + 42 \neq 0, \quad x\neq -7, \ x\neq 6, \ \]
***********************************************************************************************
** Zadanie 10 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x wyznacznik macierzy A jest różny od zera?

\[\begin{split} \textnormal{A=} \left[\begin{matrix}x - 2 & 4\\1 & 2 x - 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=2 x^{2} - 6 x \neq 0, \quad x\neq 0, \ x\neq 3, \ \]
***********************************************************************************************

Macierz odwrotna z parametrem

zadanie = gz.macierz_odwrotna_parametr(wymiar=choice([2, 3, 4]), gotowiec=True)
zadanie
('Dla jakich rzeczywistych wartości parametru $x$ macierz $A$ posiada odwrotność?\n\t\\[\n\t\t\\textnormal{A=}\\left[\\begin{matrix}x - 2 & 2 x - 4\\\\x + 2 & 4\\end{matrix}\\right]\n\t\\]\nWyznaczyć macierz odwrotną dla $x=-1.$ Wykonać sprawdzenie.\\\\',
 '$\\det A=- 2 x^{2} + 4 x\\neq 0, \\quad \n\tx\\neq 0\\ \\textnormal{oraz} \\ x\\neq 2,$\\\\\n\t$A(-1)= \\left[\\begin{matrix}-3 & -6\\\\1 & 4\\end{matrix}\\right],\\ \n\t\\det A(-1)=-6,\\ \n\tA^{-1}=- \\frac{1}{6}\\left[\\begin{matrix}4 & 6\\\\-1 & -3\\end{matrix}\\right].$')
Hide code cell source
print("\033[34m** Zadanie **" + '*' * 81 + '\033[0m')
print(zadanie[0])
print("\033[34m*\033[0m" * 95)
print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
print(zadanie[1])
print("\033[32m*\033[0m" * 95)
** Zadanie ***********************************************************************************
Dla jakich rzeczywistych wartości parametru $x$ macierz $A$ posiada odwrotność?
	\[
		\textnormal{A=}\left[\begin{matrix}x - 2 & 2 x - 4\\x + 2 & 4\end{matrix}\right]
	\]
Wyznaczyć macierz odwrotną dla $x=-1.$ Wykonać sprawdzenie.\\
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$\det A=- 2 x^{2} + 4 x\neq 0, \quad 
	x\neq 0\ \textnormal{oraz} \ x\neq 2,$\\
	$A(-1)= \left[\begin{matrix}-3 & -6\\1 & 4\end{matrix}\right],\ 
	\det A(-1)=-6,\ 
	A^{-1}=- \frac{1}{6}\left[\begin{matrix}4 & 6\\-1 & -3\end{matrix}\right].$
***********************************************************************************************
Hide code cell source
for i in range(1, ile_zadan_przykladowych + 1):
    zadanie = gz.macierz_odwrotna_parametr(wymiar=choice([2, 3, 4]), gotowiec=True)
    print(f"\033[34m** Zadanie {i} **" + '*' * 80 + '\033[0m')
    display(Markdown(zadanie[0][:79].replace('$', '*')))
    display(Latex(zadanie[0][79:].split('W')[0]))
    display(Markdown('W' + zadanie[0][79:].split('W')[1].replace('$', '*')))
    print("\033[34m*\033[0m" * 95)
    print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
    rozwiazanie = zadanie[1].replace('$\\\\\n\t$', ' $ ').split('$')
    for i in range(1, len(rozwiazanie) - 1):
        display(Latex('$$' + rozwiazanie[i] + '$$'))
    print("\033[32m*\033[0m" * 95)
** Zadanie 1 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x macierz A posiada odwrotność?

\[\begin{split} \textnormal{A=}\left[\begin{matrix}2 & x + 1 & x + 2 & -4\\-2 & 3 & 2 & -2\\x - 1 & 0 & -1 & 2\\x - 2 & -1 & -2 & 0\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=-1.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=2 x^{2} + 12 x + 16\neq 0, \quad x\neq -4\ \textnormal{oraz} \ x\neq -2, \]
\[\begin{split} A(-1)= \left[\begin{matrix}2 & 0 & 1 & -4\\-2 & 3 & 2 & -2\\-2 & 0 & -1 & 2\\-3 & -1 & -2 & 0\end{matrix}\right],\ \det A(-1)=6,\ A^{-1}=\frac{1}{6}\left[\begin{matrix}10 & -2 & 18 & -6\\22 & -2 & 42 & -12\\-26 & 4 & -48 & 12\\-3 & 0 & -3 & 0\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 2 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x macierz A posiada odwrotność?

\[\begin{split} \textnormal{A=}\left[\begin{matrix}-3 & x + 4 & x + 2\\-2 & 4 & x + 2\\-3 & x + 4 & 1\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=3.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- 2 x^{2} + 2 x + 4\neq 0, \quad x\neq -1\ \textnormal{oraz} \ x\neq 2, \]
\[\begin{split} A(3)= \left[\begin{matrix}-3 & 7 & 5\\-2 & 4 & 5\\-3 & 7 & 1\end{matrix}\right],\ \det A(3)=-8,\ A^{-1}=- \frac{1}{8}\left[\begin{matrix}-31 & 28 & 15\\-13 & 12 & 5\\-2 & 0 & 2\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 3 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x macierz A posiada odwrotność?

\[\begin{split} \textnormal{A=}\left[\begin{matrix}1 & 1 & 2 & 1\\-3 & x - 3 & x + 2 & x + 3\\0 & 3 & -1 & 2\\x + 4 & 4 & -4 & -4\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=3.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- x^{2} - 14 x - 24\neq 0, \quad x\neq -12\ \textnormal{oraz} \ x\neq -2, \]
\[\begin{split} A(3)= \left[\begin{matrix}1 & 1 & 2 & 1\\-3 & 0 & 5 & 6\\0 & 3 & -1 & 2\\7 & 4 & -4 & -4\end{matrix}\right],\ \det A(3)=-75,\ A^{-1}=- \frac{1}{75}\left[\begin{matrix}52 & -44 & 32 & -37\\-76 & 47 & -41 & 31\\-66 & 27 & -6 & 21\\81 & -57 & 21 & -36\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 4 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x macierz A posiada odwrotność?

\[\begin{split} \textnormal{A=}\left[\begin{matrix}x - 2 & 0 & -1\\2 x - 1 & x - 4 & 1\\-1 & -1 & -1\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=2.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- x^{2} + 8 x - 7\neq 0, \quad x\neq 1\ \textnormal{oraz} \ x\neq 7, \]
\[\begin{split} A(2)= \left[\begin{matrix}0 & 0 & -1\\3 & -2 & 1\\-1 & -1 & -1\end{matrix}\right],\ \det A(2)=5,\ A^{-1}=\frac{1}{5}\left[\begin{matrix}3 & 1 & -2\\2 & -1 & -3\\-5 & 0 & 0\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 5 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x macierz A posiada odwrotność?

\[\begin{split} \textnormal{A=}\left[\begin{matrix}x - 3 & x - 1\\-2 & 2 x - 2\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=3.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=2 x^{2} - 6 x + 4\neq 0, \quad x\neq 1\ \textnormal{oraz} \ x\neq 2, \]
\[\begin{split} A(3)= \left[\begin{matrix}0 & 2\\-2 & 4\end{matrix}\right],\ \det A(3)=4,\ A^{-1}=\frac{1}{4}\left[\begin{matrix}4 & -2\\2 & 0\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 6 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x macierz A posiada odwrotność?

\[\begin{split} \textnormal{A=}\left[\begin{matrix}-1 & 0 & 1\\x - 3 & x + 4 & x - 1\\-3 & 1 & x + 1\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=-1.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=4 - x^{2}\neq 0, \quad x\neq -2\ \textnormal{oraz} \ x\neq 2, \]
\[\begin{split} A(-1)= \left[\begin{matrix}-1 & 0 & 1\\-4 & 3 & -2\\-3 & 1 & 0\end{matrix}\right],\ \det A(-1)=3,\ A^{-1}=\frac{1}{3}\left[\begin{matrix}2 & 1 & -3\\6 & 3 & -6\\5 & 1 & -3\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 7 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x macierz A posiada odwrotność?

\[\begin{split} \textnormal{A=}\left[\begin{matrix}x + 3 & 2 & 1 & 0\\-4 & 0 & x - 4 & 3\\x + 3 & -2 & 4 & -3\\x - 4 & 4 & 3 & 1\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=-2.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- 2 x^{2} - 82 x - 80\neq 0, \quad x\neq -40\ \textnormal{oraz} \ x\neq -1, \]
\[\begin{split} A(-2)= \left[\begin{matrix}1 & 2 & 1 & 0\\-4 & 0 & -6 & 3\\1 & -2 & 4 & -3\\-6 & 4 & 3 & 1\end{matrix}\right],\ \det A(-2)=76,\ A^{-1}=\frac{1}{76}\left[\begin{matrix}-6 & -16 & -18 & -6\\73 & 30 & 29 & -3\\-64 & -44 & -40 & 12\\-136 & -84 & -104 & 16\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 8 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x macierz A posiada odwrotność?

\[\begin{split} \textnormal{A=}\left[\begin{matrix}1 & 1 & -2\\-3 & -3 & x + 4\\-3 & 2 x - 3 & x + 3\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=-1.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- 2 x^{2} + 4 x\neq 0, \quad x\neq 0\ \textnormal{oraz} \ x\neq 2, \]
\[\begin{split} A(-1)= \left[\begin{matrix}1 & 1 & -2\\-3 & -3 & 3\\-3 & -5 & 2\end{matrix}\right],\ \det A(-1)=-6,\ A^{-1}=- \frac{1}{6}\left[\begin{matrix}9 & 8 & -3\\-3 & -4 & 3\\6 & 2 & 0\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 9 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x macierz A posiada odwrotność?

\[\begin{split} \textnormal{A=}\left[\begin{matrix}1 & -4 & 2 x - 2 & x - 2\\0 & -2 & -1 & -2\\x & 2 & 2 & 4\\1 & -4 & -3 & -4\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=-2.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=2 x^{2} - 2 x\neq 0, \quad x\neq 0\ \textnormal{oraz} \ x\neq 1, \]
\[\begin{split} A(-2)= \left[\begin{matrix}1 & -4 & -6 & -4\\0 & -2 & -1 & -2\\-2 & 2 & 2 & 4\\1 & -4 & -3 & -4\end{matrix}\right],\ \det A(-2)=12,\ A^{-1}=\frac{1}{12}\left[\begin{matrix}-4 & -24 & 0 & 16\\4 & 12 & -6 & -16\\-4 & 0 & 0 & 4\\-2 & -18 & 6 & 14\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 10 **********************************************************************************

Dla jakich rzeczywistych wartości parametru x macierz A posiada odwrotność?

\[\begin{split} \textnormal{A=}\left[\begin{matrix}3 & -1 & 1 & 1\\2 x + 2 & 0 & x + 2 & 2\\-3 & -1 & -3 & 1\\1 & x - 2 & -2 & 0\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=3.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- 2 x^{2} + 20 x\neq 0, \quad x\neq 0\ \textnormal{oraz} \ x\neq 10, \]
\[\begin{split} A(3)= \left[\begin{matrix}3 & -1 & 1 & 1\\8 & 0 & 5 & 2\\-3 & -1 & -3 & 1\\1 & 1 & -2 & 0\end{matrix}\right],\ \det A(3)=42,\ A^{-1}=\frac{1}{42}\left[\begin{matrix}15 & -4 & -7 & 8\\-39 & 16 & 7 & 10\\-12 & 6 & 0 & -12\\-30 & 22 & 28 & -2\end{matrix}\right].\end{split}\]
***********************************************************************************************

Wektory własne

zadanie = gz.wartosci_wlasne(wymiar=choice([2, 3, 4]), zespolone=choice([False, True]))
zadanie
('Wyznaczyć wartości własne i wektory własne macierzy \n\t\\[\n\t\t\\textnormal{A=} \\left[\\begin{matrix}2 & 2 & 3 & 3\\\\1 & -2 & -1 & -1\\\\3 & 2 & 0 & -1\\\\3 & 1 & -1 & 0\\end{matrix}\\right]\n\t\\]',
 '$\\det\\left(\\lambda \\mathbb{I} - A \\right) = \\lambda^{4} - 22 \\lambda^{2} - 24 \\lambda + 45$, \\quad \nWartości własne:$ \\left\\{ -3 : 2, \\  1 : 1, \\  5 : 1\\right\\}, $\\\\\n\t\\parbox{4em}{Wektory\\\\własne:} $\\left[ \\left( -3, \\  2, \\  \\left[ \\left[\\begin{matrix}-2\\\\\\frac{16}{5}\\\\\\frac{1}{5}\\\\1\\end{matrix}\\right]\\right]\\right), \\  \\left( 1, \\  1, \\  \\left[ \\left[\\begin{matrix}0\\\\0\\\\-1\\\\1\\end{matrix}\\right]\\right]\\right), \\  \\left( 5, \\  1, \\  \\left[ \\left[\\begin{matrix}2\\\\0\\\\1\\\\1\\end{matrix}\\right]\\right]\\right)\\right]$')
Hide code cell source
print("\033[34m** Zadanie **" + '*' * 81 + '\033[0m')
print(zadanie[0])
print("\033[34m*\033[0m" * 95)
print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
print(zadanie[1])
print("\033[32m*\033[0m" * 95)
** Zadanie ***********************************************************************************
Wyznaczyć wartości własne i wektory własne macierzy 
	\[
		\textnormal{A=} \left[\begin{matrix}2 & 2 & 3 & 3\\1 & -2 & -1 & -1\\3 & 2 & 0 & -1\\3 & 1 & -1 & 0\end{matrix}\right]
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} - 22 \lambda^{2} - 24 \lambda + 45$, \quad 
Wartości własne:$ \left\{ -3 : 2, \  1 : 1, \  5 : 1\right\}, $\\
	\parbox{4em}{Wektory\\własne:} $\left[ \left( -3, \  2, \  \left[ \left[\begin{matrix}-2\\\frac{16}{5}\\\frac{1}{5}\\1\end{matrix}\right]\right]\right), \  \left( 1, \  1, \  \left[ \left[\begin{matrix}0\\0\\-1\\1\end{matrix}\right]\right]\right), \  \left( 5, \  1, \  \left[ \left[\begin{matrix}2\\0\\1\\1\end{matrix}\right]\right]\right)\right]$
***********************************************************************************************
Hide code cell source
for i in range(1, ile_zadan_przykladowych + 1):
    zadanie = gz.wartosci_wlasne(wymiar=choice([2, 3, 4]), zespolone=choice([False, True]))
    print(f"\033[34m** Zadanie {i} **" + '*' * 80 + '\033[0m')
    display(Markdown(zadanie[0][:51]))
    display(Latex(zadanie[0][51:]))
    print("\033[34m*\033[0m" * 95)
    print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
    display(Latex(zadanie[1].split(', \quad')[0].replace("$", "$$")))
    display(Markdown("Wartości własne"))
    display(Latex("$$" + (zadanie[1].split(', \quad')[1]).split("$")[1] + "$$"))
    display(Markdown("Wektory własne"))
    display(Latex("$$" + (zadanie[1].split(', \quad')[1]).split("$")[3] + "$$"))
    print("\033[32m*\033[0m" * 95)
** Zadanie 1 **********************************************************************************

Wyznaczyć wartości własne i wektory własne macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}3 & 2\\1 & 3\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - 6 \lambda + 7\]

Wartości własne

\[ \left\{ 3 - \sqrt{2} : 1, \ \sqrt{2} + 3 : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 3 - \sqrt{2}, \ 1, \ \left[ \left[\begin{matrix}- \sqrt{2}\\1\end{matrix}\right]\right]\right), \ \left( \sqrt{2} + 3, \ 1, \ \left[ \left[\begin{matrix}\sqrt{2}\\1\end{matrix}\right]\right]\right)\right]\end{split}\]
***********************************************************************************************
** Zadanie 2 **********************************************************************************

Wyznaczyć wartości własne i wektory własne macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-1 & -1 & 1 & 0\\-1 & 0 & 0 & 2\\2 & 1 & 0 & 0\\2 & 1 & 0 & 0\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} + \lambda^{3} - 5 \lambda^{2} + 3 \lambda\]

Wartości własne

\[ \left\{ -3 : 1, \ 0 : 1, \ 1 : 2\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( -3, \ 1, \ \left[ \left[\begin{matrix}-1\\-1\\1\\1\end{matrix}\right]\right]\right), \ \left( 0, \ 1, \ \left[ \left[\begin{matrix}2\\-4\\-2\\1\end{matrix}\right]\right]\right), \ \left( 1, \ 2, \ \left[ \left[\begin{matrix}-1\\3\\1\\1\end{matrix}\right]\right]\right)\right]\end{split}\]
***********************************************************************************************
** Zadanie 3 **********************************************************************************

Wyznaczyć wartości własne i wektory własne macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}2 & -1 & -2\\-2 & 2 & -1\\-2 & -2 & 3\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{3} - 7 \lambda^{2} + 8 \lambda + 16\]

Wartości własne

\[ \left\{ -1 : 1, \ 4 : 2\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( -1, \ 1, \ \left[ \left[\begin{matrix}1\\1\\1\end{matrix}\right]\right]\right), \ \left( 4, \ 2, \ \left[ \left[\begin{matrix}- \frac{3}{2}\\1\\1\end{matrix}\right]\right]\right)\right]\end{split}\]
***********************************************************************************************
** Zadanie 4 **********************************************************************************

Wyznaczyć wartości własne i wektory własne macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}3 & 2\\-2 & 3\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - 6 \lambda + 13\]

Wartości własne

\[ \left\{ 3 - 2 i : 1, \ 3 + 2 i : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 3 - 2 i, \ 1, \ \left[ \left[\begin{matrix}i\\1\end{matrix}\right]\right]\right), \ \left( 3 + 2 i, \ 1, \ \left[ \left[\begin{matrix}- i\\1\end{matrix}\right]\right]\right)\right]\end{split}\]
***********************************************************************************************
** Zadanie 5 **********************************************************************************

Wyznaczyć wartości własne i wektory własne macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}0 & -1\\2 & 3\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - 3 \lambda + 2\]

Wartości własne

\[ \left\{ 1 : 1, \ 2 : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 1, \ 1, \ \left[ \left[\begin{matrix}-1\\1\end{matrix}\right]\right]\right), \ \left( 2, \ 1, \ \left[ \left[\begin{matrix}- \frac{1}{2}\\1\end{matrix}\right]\right]\right)\right]\end{split}\]
***********************************************************************************************
** Zadanie 6 **********************************************************************************

Wyznaczyć wartości własne i wektory własne macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}3 & 2 & -2\\-1 & -2 & 2\\0 & -2 & 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{3} - 3 \lambda^{2} + 2 \lambda\]

Wartości własne

\[ \left\{ 0 : 1, \ 1 : 1, \ 2 : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 0, \ 1, \ \left[ \left[\begin{matrix}0\\1\\1\end{matrix}\right]\right]\right), \ \left( 1, \ 1, \ \left[ \left[\begin{matrix}\frac{1}{2}\\\frac{1}{2}\\1\end{matrix}\right]\right]\right), \ \left( 2, \ 1, \ \left[ \left[\begin{matrix}2\\0\\1\end{matrix}\right]\right]\right)\right]\end{split}\]
***********************************************************************************************
** Zadanie 7 **********************************************************************************

Wyznaczyć wartości własne i wektory własne macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}1 & -2\\1 & 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - 3 \lambda + 4\]

Wartości własne

\[ \left\{ \frac{3}{2} - \frac{\sqrt{7} i}{2} : 1, \ \frac{3}{2} + \frac{\sqrt{7} i}{2} : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( \frac{3}{2} - \frac{\sqrt{7} i}{2}, \ 1, \ \left[ \left[\begin{matrix}- \frac{1}{2} - \frac{\sqrt{7} i}{2}\\1\end{matrix}\right]\right]\right), \ \left( \frac{3}{2} + \frac{\sqrt{7} i}{2}, \ 1, \ \left[ \left[\begin{matrix}- \frac{1}{2} + \frac{\sqrt{7} i}{2}\\1\end{matrix}\right]\right]\right)\right]\end{split}\]
***********************************************************************************************
** Zadanie 8 **********************************************************************************

Wyznaczyć wartości własne i wektory własne macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}0 & 2\\-2 & -2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} + 2 \lambda + 4\]

Wartości własne

\[ \left\{ -1 - \sqrt{3} i : 1, \ -1 + \sqrt{3} i : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( -1 - \sqrt{3} i, \ 1, \ \left[ \left[\begin{matrix}- \frac{1}{2} + \frac{\sqrt{3} i}{2}\\1\end{matrix}\right]\right]\right), \ \left( -1 + \sqrt{3} i, \ 1, \ \left[ \left[\begin{matrix}- \frac{1}{2} - \frac{\sqrt{3} i}{2}\\1\end{matrix}\right]\right]\right)\right]\end{split}\]
***********************************************************************************************
** Zadanie 9 **********************************************************************************

Wyznaczyć wartości własne i wektory własne macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}3 & 1 & -1\\3 & 1 & 2\\0 & 0 & 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{3} - 6 \lambda^{2} + 8 \lambda\]

Wartości własne

\[ \left\{ 0 : 1, \ 2 : 1, \ 4 : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 0, \ 1, \ \left[ \left[\begin{matrix}- \frac{1}{3}\\1\\0\end{matrix}\right]\right]\right), \ \left( 2, \ 1, \ \left[ \left[\begin{matrix}- \frac{1}{4}\\\frac{5}{4}\\1\end{matrix}\right]\right]\right), \ \left( 4, \ 1, \ \left[ \left[\begin{matrix}1\\1\\0\end{matrix}\right]\right]\right)\right]\end{split}\]
***********************************************************************************************
** Zadanie 10 **********************************************************************************

Wyznaczyć wartości własne i wektory własne macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}2 & 3 & -1 & 1\\0 & -1 & 0 & 2\\-2 & -2 & 3 & -2\\0 & 0 & 1 & -1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} - 3 \lambda^{3} - 3 \lambda^{2} + 7 \lambda + 6\]

Wartości własne

\[ \left\{ -1 : 2, \ 2 : 1, \ 3 : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( -1, \ 2, \ \left[ \left[\begin{matrix}-1\\1\\0\\0\end{matrix}\right]\right]\right), \ \left( 2, \ 1, \ \left[ \left[\begin{matrix}- \frac{1}{6}\\\frac{2}{3}\\3\\1\end{matrix}\right]\right]\right), \ \left( 3, \ 1, \ \left[ \left[\begin{matrix}- \frac{3}{2}\\\frac{1}{2}\\4\\1\end{matrix}\right]\right]\right)\right]\end{split}\]
***********************************************************************************************

Rząd macierzy

zadanie = gz.rzad_macierzy()
zadanie
('Wyznaczyć rząd macierzy A\n\t\\[\n\t\t\\textnormal{A=} \\left[\\begin{matrix}0 & 0 & 0 & 0 & -2\\\\-1 & -2 & 3 & 0 & 1\\\\2 & 0 & 2 & 2 & -1\\\\1 & 0 & -1 & -1 & -2\\\\-2 & 2 & -1 & 2 & 0\\end{matrix}\\right]\n\t\\]',
 '$R(A)= 4$')
Hide code cell source
print("\033[34m** Zadanie **" + '*' * 81 + '\033[0m')
print(zadanie[0])
print("\033[34m*\033[0m" * 95)
print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
print(zadanie[1])
print("\033[32m*\033[0m" * 95)
** Zadanie ***********************************************************************************
Wyznaczyć rząd macierzy A
	\[
		\textnormal{A=} \left[\begin{matrix}0 & 0 & 0 & 0 & -2\\-1 & -2 & 3 & 0 & 1\\2 & 0 & 2 & 2 & -1\\1 & 0 & -1 & -1 & -2\\-2 & 2 & -1 & 2 & 0\end{matrix}\right]
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$R(A)= 4$
***********************************************************************************************
Hide code cell source
for i in range(1, ile_zadan_przykladowych + 1):
    zadanie = gz.rzad_macierzy()
    print(f"\033[34m** Zadanie {i} **" + '*' * 80 + '\033[0m')
    display(Markdown(zadanie[0][:25].replace('A', '*A*')))
    display(Latex(zadanie[0][25:]))
    print("\033[34m*\033[0m" * 95)
    print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
    display(Latex(zadanie[1].replace("$", "$$")))
    print("\033[32m*\033[0m" * 95)
** Zadanie 1 **********************************************************************************

Wyznaczyć rząd macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}0 & 0 & 1 & 3\\-1 & -2 & -2 & 1\\1 & 2 & 1 & -1\\1 & 2 & -1 & -2\\0 & 0 & -1 & 3\\1 & 2 & -1 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[R(A)= 3\]
***********************************************************************************************
** Zadanie 2 **********************************************************************************

Wyznaczyć rząd macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}2 & -2 & 2 & -1 & -2 & 1\\3 & -2 & 0 & 1 & 1 & -2\\3 & -1 & -1 & 0 & 0 & 0\\3 & -1 & -1 & 0 & 0 & 0\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[R(A)= 3\]
***********************************************************************************************
** Zadanie 3 **********************************************************************************

Wyznaczyć rząd macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}2 & -2 & -2 & -2 & -2 & 3\\-2 & -2 & 3 & 2 & 0 & 3\\2 & -2 & -2 & -2 & -2 & 3\\0 & 2 & 2 & 2 & 2 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[R(A)= 3\]
***********************************************************************************************
** Zadanie 4 **********************************************************************************

Wyznaczyć rząd macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-2 & -1 & 2 & 1 & 0 & 2\\0 & 3 & -2 & -1 & 2 & 0\\-1 & 2 & 2 & 3 & 0 & 2\\1 & 0 & 2 & 3 & -2 & 0\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[R(A)= 3\]
***********************************************************************************************
** Zadanie 5 **********************************************************************************

Wyznaczyć rząd macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}1 & -2 & 1 & -2 & -2 & -1\\2 & 1 & -2 & 3 & 3 & -1\\-2 & -1 & 3 & 1 & -1 & 3\\-1 & 2 & -1 & -2 & 3 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[R(A)= 4\]
***********************************************************************************************
** Zadanie 6 **********************************************************************************

Wyznaczyć rząd macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-1 & 3 & 2 & 3 & -2 & 3\\-2 & 3 & -1 & -2 & -1 & 3\\0 & 1 & -2 & -2 & -2 & -2\\0 & 1 & -2 & -2 & -2 & -2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[R(A)= 3\]
***********************************************************************************************
** Zadanie 7 **********************************************************************************

Wyznaczyć rząd macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}0 & 1 & 0 & 2 & 2\\1 & 0 & 0 & 0 & -1\\2 & 1 & 0 & 1 & -1\\-2 & 3 & -2 & 2 & 3\\-1 & -1 & 0 & 0 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[R(A)= 4\]
***********************************************************************************************
** Zadanie 8 **********************************************************************************

Wyznaczyć rząd macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-2 & 0 & 1 & -1 & 1 & -1\\0 & -1 & 0 & 0 & 1 & 2\\2 & 2 & -2 & 3 & -2 & 0\\-2 & 1 & 0 & 1 & 1 & 0\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[R(A)= 3\]
***********************************************************************************************
** Zadanie 9 **********************************************************************************

Wyznaczyć rząd macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}1 & 2 & -2 & -1 & 1 & -2\\2 & 1 & -2 & 1 & 2 & -1\\-1 & 3 & -1 & -1 & 2 & 0\\-1 & 1 & 0 & -2 & -1 & -1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[R(A)= 3\]
***********************************************************************************************
** Zadanie 10 **********************************************************************************

Wyznaczyć rząd macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-1 & 0 & 2 & 0\\3 & 0 & 0 & 0\\1 & 1 & -1 & -1\\0 & -2 & 1 & 2\\3 & 2 & -1 & -2\\0 & -1 & -2 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[R(A)= 3\]
***********************************************************************************************

Diagonalizacja macierzy

zadanie = gz.diagonalizacja_macierzy(wymiar=choice([2, 3, 4]))
zadanie
('Przeprowadzić diagonalizację macierzy (jeśli możliwa) \n\t\\[\n\t\t\\textnormal{A=} \\left[\\begin{matrix}-2 & 0 & 3\\\\0 & 2 & 2\\\\-1 & 0 & 2\\end{matrix}\\right]\n\t\\]',
 '$\\det\\left(\\lambda \\mathbb{I} - A \\right) = \\lambda^{3} - 2 \\lambda^{2} - \\lambda + 2$, \\quad \nWartości własne:$ \\left\\{ -1 : 1, \\  1 : 1, \\  2 : 1\\right\\}, $\\\\\n\\parbox{4em}{Wektory\\\\własne:} $\\left[ \\left( -1, \\  1, \\  \\left[ \\left[\\begin{matrix}3\\\\- \\frac{2}{3}\\\\1\\end{matrix}\\right]\\right]\\right), \\  \\left( 1, \\  1, \\  \\left[ \\left[\\begin{matrix}1\\\\-2\\\\1\\end{matrix}\\right]\\right]\\right), \\  \\left( 2, \\  1, \\  \\left[ \\left[\\begin{matrix}0\\\\1\\\\0\\end{matrix}\\right]\\right]\\right)\\right]$,\\\\\n$A = P\\,D\\,P^{-1}: \\quad P=\\left[\\begin{matrix}9 & 1 & 0\\\\-2 & -2 & 1\\\\3 & 1 & 0\\end{matrix}\\right],$ \\quad \n$D=\\left[\\begin{matrix}-1 & 0 & 0\\\\0 & 1 & 0\\\\0 & 0 & 2\\end{matrix}\\right]$')
Hide code cell source
print("\033[34m** Zadanie **" + '*' * 81 + '\033[0m')
print(zadanie[0])
print("\033[34m*\033[0m" * 95)
print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
print(zadanie[1])
print("\033[32m*\033[0m" * 95)
** Zadanie ***********************************************************************************
Przeprowadzić diagonalizację macierzy (jeśli możliwa) 
	\[
		\textnormal{A=} \left[\begin{matrix}-2 & 0 & 3\\0 & 2 & 2\\-1 & 0 & 2\end{matrix}\right]
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$\det\left(\lambda \mathbb{I} - A \right) = \lambda^{3} - 2 \lambda^{2} - \lambda + 2$, \quad 
Wartości własne:$ \left\{ -1 : 1, \  1 : 1, \  2 : 1\right\}, $\\
\parbox{4em}{Wektory\\własne:} $\left[ \left( -1, \  1, \  \left[ \left[\begin{matrix}3\\- \frac{2}{3}\\1\end{matrix}\right]\right]\right), \  \left( 1, \  1, \  \left[ \left[\begin{matrix}1\\-2\\1\end{matrix}\right]\right]\right), \  \left( 2, \  1, \  \left[ \left[\begin{matrix}0\\1\\0\end{matrix}\right]\right]\right)\right]$,\\
$A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}9 & 1 & 0\\-2 & -2 & 1\\3 & 1 & 0\end{matrix}\right],$ \quad 
$D=\left[\begin{matrix}-1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 2\end{matrix}\right]$
***********************************************************************************************
Hide code cell source
for i in range(1, ile_zadan_przykladowych + 1):
    zadanie = gz.diagonalizacja_macierzy(wymiar=choice([2, 3, 4]))
    print(f"\033[34m** Zadanie {i} **" + '*' * 80 + '\033[0m')
    display(Markdown(zadanie[0][:53]))
    display(Latex(zadanie[0][53:]))
    print("\033[34m*\033[0m" * 95)
    print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
    display(Latex(zadanie[1].split(', \quad')[0].replace("$", "$$")))
    display(Markdown("Wartości własne"))
    display(Latex("$$" + (zadanie[1].split(', \quad')[1]).split("$")[1] + "$$"))
    display(Markdown("Wektory własne"))
    display(Latex("$$" + (zadanie[1].split(', \quad')[1]).split("$")[3] + "$$"))
    display(Markdown("Diagonalizacja:"))
    try:
        display(Latex("$$" + (zadanie[1].split(', \quad')[1]).split("$")[5]
                      + '\quad ' + (zadanie[1].split(', \quad')[1]).split("$")[7] + "$$"))
    except Exception:
        display(Markdown("Macierz nie jest diagonalizowalna"))
    print("\033[32m*\033[0m" * 95)
** Zadanie 1 **********************************************************************************

Przeprowadzić diagonalizację macierzy (jeśli możliwa)

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-1 & 0 & 0\\2 & 3 & 0\\0 & -1 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{3} - 3 \lambda^{2} - \lambda + 3\]

Wartości własne

\[ \left\{ -1 : 1, \ 1 : 1, \ 3 : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( -1, \ 1, \ \left[ \left[\begin{matrix}-4\\2\\1\end{matrix}\right]\right]\right), \ \left( 1, \ 1, \ \left[ \left[\begin{matrix}0\\0\\1\end{matrix}\right]\right]\right), \ \left( 3, \ 1, \ \left[ \left[\begin{matrix}0\\-2\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}-4 & 0 & 0\\2 & 0 & -2\\1 & 1 & 1\end{matrix}\right],\quad D=\left[\begin{matrix}-1 & 0 & 0\\0 & 1 & 0\\0 & 0 & 3\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 2 **********************************************************************************

Przeprowadzić diagonalizację macierzy (jeśli możliwa)

\[\begin{split} \textnormal{A=} \left[\begin{matrix}3 & 0 & 0\\0 & 2 & 0\\0 & 3 & -1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{3} - 4 \lambda^{2} + \lambda + 6\]

Wartości własne

\[ \left\{ -1 : 1, \ 2 : 1, \ 3 : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( -1, \ 1, \ \left[ \left[\begin{matrix}0\\0\\1\end{matrix}\right]\right]\right), \ \left( 2, \ 1, \ \left[ \left[\begin{matrix}0\\1\\1\end{matrix}\right]\right]\right), \ \left( 3, \ 1, \ \left[ \left[\begin{matrix}1\\0\\0\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}0 & 0 & 1\\0 & 1 & 0\\1 & 1 & 0\end{matrix}\right],\quad D=\left[\begin{matrix}-1 & 0 & 0\\0 & 2 & 0\\0 & 0 & 3\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 3 **********************************************************************************

Przeprowadzić diagonalizację macierzy (jeśli możliwa)

\[\begin{split} \textnormal{A=} \left[\begin{matrix}0 & 3 & -2\\1 & 2 & 0\\2 & 0 & 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{3} - 4 \lambda^{2} + 5 \lambda - 2\]

Wartości własne

\[ \left\{ 1 : 2, \ 2 : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 1, \ 2, \ \left[ \left[\begin{matrix}- \frac{1}{2}\\\frac{1}{2}\\1\end{matrix}\right]\right]\right), \ \left( 2, \ 1, \ \left[ \left[\begin{matrix}0\\\frac{2}{3}\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

Macierz nie jest diagonalizowalna

***********************************************************************************************
** Zadanie 4 **********************************************************************************

Przeprowadzić diagonalizację macierzy (jeśli możliwa)

\[\begin{split} \textnormal{A=} \left[\begin{matrix}2 & 0\\3 & 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - 4 \lambda + 4\]

Wartości własne

\[ \left\{ 2 : 2\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 2, \ 2, \ \left[ \left[\begin{matrix}0\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

Macierz nie jest diagonalizowalna

***********************************************************************************************
** Zadanie 5 **********************************************************************************

Przeprowadzić diagonalizację macierzy (jeśli możliwa)

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-1 & 0 & 1 & -1\\0 & 1 & 1 & 0\\1 & 0 & -2 & 3\\-1 & 0 & 0 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} + \lambda^{3} - 5 \lambda^{2} + 3 \lambda\]

Wartości własne

\[ \left\{ -3 : 1, \ 0 : 1, \ 1 : 2\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( -3, \ 1, \ \left[ \left[\begin{matrix}4\\\frac{7}{4}\\-7\\1\end{matrix}\right]\right]\right), \ \left( 0, \ 1, \ \left[ \left[\begin{matrix}1\\-2\\2\\1\end{matrix}\right]\right]\right), \ \left( 1, \ 2, \ \left[ \left[\begin{matrix}0\\1\\0\\0\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

Macierz nie jest diagonalizowalna

***********************************************************************************************
** Zadanie 6 **********************************************************************************

Przeprowadzić diagonalizację macierzy (jeśli możliwa)

\[\begin{split} \textnormal{A=} \left[\begin{matrix}0 & -2\\-1 & -1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} + \lambda - 2\]

Wartości własne

\[ \left\{ -2 : 1, \ 1 : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( -2, \ 1, \ \left[ \left[\begin{matrix}1\\1\end{matrix}\right]\right]\right), \ \left( 1, \ 1, \ \left[ \left[\begin{matrix}-2\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}1 & -2\\1 & 1\end{matrix}\right],\quad D=\left[\begin{matrix}-2 & 0\\0 & 1\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 7 **********************************************************************************

Przeprowadzić diagonalizację macierzy (jeśli możliwa)

\[\begin{split} \textnormal{A=} \left[\begin{matrix}2 & -1 & 1 & 2\\1 & 2 & 2 & -1\\1 & 2 & 2 & -1\\1 & -1 & -2 & -2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} - 4 \lambda^{3} - 9 \lambda^{2} + 36 \lambda\]

Wartości własne

\[ \left\{ -3 : 1, \ 0 : 1, \ 3 : 1, \ 4 : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( -3, \ 1, \ \left[ \left[\begin{matrix}- \frac{2}{5}\\\frac{1}{5}\\\frac{1}{5}\\1\end{matrix}\right]\right]\right), \ \left( 0, \ 1, \ \left[ \left[\begin{matrix}\frac{7}{11}\\\frac{19}{11}\\- \frac{17}{11}\\1\end{matrix}\right]\right]\right), \ \left( 3, \ 1, \ \left[ \left[\begin{matrix}2\\-1\\-1\\1\end{matrix}\right]\right]\right), \ \left( 4, \ 1, \ \left[ \left[\begin{matrix}1\\- \frac{5}{3}\\- \frac{5}{3}\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}-2 & 7 & 2 & 3\\1 & 19 & -1 & -5\\1 & -17 & -1 & -5\\5 & 11 & 1 & 3\end{matrix}\right],\quad D=\left[\begin{matrix}-3 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 3 & 0\\0 & 0 & 0 & 4\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 8 **********************************************************************************

Przeprowadzić diagonalizację macierzy (jeśli możliwa)

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-2 & 0 & 0 & 0\\2 & 0 & 0 & 0\\1 & 1 & 2 & -1\\0 & 2 & 0 & -2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} + 2 \lambda^{3} - 4 \lambda^{2} - 8 \lambda\]

Wartości własne

\[ \left\{ -2 : 2, \ 0 : 1, \ 2 : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( -2, \ 2, \ \left[ \left[\begin{matrix}0\\0\\\frac{1}{4}\\1\end{matrix}\right]\right]\right), \ \left( 0, \ 1, \ \left[ \left[\begin{matrix}0\\1\\0\\1\end{matrix}\right]\right]\right), \ \left( 2, \ 1, \ \left[ \left[\begin{matrix}0\\0\\1\\0\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

Macierz nie jest diagonalizowalna

***********************************************************************************************
** Zadanie 9 **********************************************************************************

Przeprowadzić diagonalizację macierzy (jeśli możliwa)

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-1 & 0\\-2 & 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - \lambda - 2\]

Wartości własne

\[ \left\{ -1 : 1, \ 2 : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( -1, \ 1, \ \left[ \left[\begin{matrix}\frac{3}{2}\\1\end{matrix}\right]\right]\right), \ \left( 2, \ 1, \ \left[ \left[\begin{matrix}0\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}3 & 0\\2 & 1\end{matrix}\right],\quad D=\left[\begin{matrix}-1 & 0\\0 & 2\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 10 **********************************************************************************

Przeprowadzić diagonalizację macierzy (jeśli możliwa)

\[\begin{split} \textnormal{A=} \left[\begin{matrix}2 & 0\\-1 & 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - 4 \lambda + 4\]

Wartości własne

\[ \left\{ 2 : 2\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 2, \ 2, \ \left[ \left[\begin{matrix}0\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

Macierz nie jest diagonalizowalna

***********************************************************************************************

Diagonalizacja z wielokrotnymi wartościamy własnymi

zadanie = gz.diagonalizacja_macierzy_z_wielokrotnym_wartosciami_wlasnymi(wymiar=choice([2, 3, 4]))
zadanie
('Przeprowadzić diagonalizację macierzy\n\t\\[\n\t\t\\textnormal{A=} \\left[\\begin{matrix}-1 & 0 & -1 & -2\\\\0 & 1 & 3 & 0\\\\3 & 0 & 1 & 3\\\\-2 & 0 & 3 & -1\\end{matrix}\\right]\n\t\\]',
 '$\\det\\left(\\lambda \\mathbb{I} - A \\right) = \\lambda^{4} - 12 \\lambda^{2} + 20 \\lambda - 9$, \\quad \nWartości własne:$ \\left\\{ 1 : 2, \\  -1 + \\sqrt{10} : 1, \\  - \\sqrt{10} - 1 : 1\\right\\}, $\\\\\n\\parbox{4em}{Wektory\\\\własne:} $\\left[ \\left( 1, \\  2, \\  \\left[ \\left[\\begin{matrix}0\\\\1\\\\0\\\\0\\end{matrix}\\right], \\  \\left[\\begin{matrix}-1\\\\0\\\\0\\\\1\\end{matrix}\\right]\\right]\\right), \\  \\left( -1 + \\sqrt{10}, \\  1, \\  \\left[ \\left[\\begin{matrix}- \\frac{8 \\sqrt{10}}{43} - \\frac{9}{43}\\\\\\frac{6 \\sqrt{10}}{43} + \\frac{39}{43}\\\\- \\frac{6}{43} + \\frac{9 \\sqrt{10}}{43}\\\\1\\end{matrix}\\right]\\right]\\right), \\  \\left( - \\sqrt{10} - 1, \\  1, \\  \\left[ \\left[\\begin{matrix}- \\frac{9}{43} + \\frac{8 \\sqrt{10}}{43}\\\\\\frac{39}{43} - \\frac{6 \\sqrt{10}}{43}\\\\- \\frac{9 \\sqrt{10}}{43} - \\frac{6}{43}\\\\1\\end{matrix}\\right]\\right]\\right)\\right]$,\\\\\n$A = P\\,D\\,P^{-1}: \\quad P=\\left[\\begin{matrix}0 & -1 & - \\frac{8 \\sqrt{10}}{43} - \\frac{9}{43} & - \\frac{9}{43} + \\frac{8 \\sqrt{10}}{43}\\\\1 & 0 & \\frac{6 \\sqrt{10}}{43} + \\frac{39}{43} & \\frac{39}{43} - \\frac{6 \\sqrt{10}}{43}\\\\0 & 0 & - \\frac{6}{43} + \\frac{9 \\sqrt{10}}{43} & - \\frac{9 \\sqrt{10}}{43} - \\frac{6}{43}\\\\0 & 1 & 1 & 1\\end{matrix}\\right],$ \\quad \n$D=\\left[\\begin{matrix}1 & 0 & 0 & 0\\\\0 & 1 & 0 & 0\\\\0 & 0 & -1 + \\sqrt{10} & 0\\\\0 & 0 & 0 & - \\sqrt{10} - 1\\end{matrix}\\right]$')
Hide code cell source
print("\033[34m** Zadanie **" + '*' * 81 + '\033[0m')
print(zadanie[0])
print("\033[34m*\033[0m" * 95)
print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
print(zadanie[1])
print("\033[32m*\033[0m" * 95)
** Zadanie ***********************************************************************************
Przeprowadzić diagonalizację macierzy
	\[
		\textnormal{A=} \left[\begin{matrix}-1 & 0 & -1 & -2\\0 & 1 & 3 & 0\\3 & 0 & 1 & 3\\-2 & 0 & 3 & -1\end{matrix}\right]
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} - 12 \lambda^{2} + 20 \lambda - 9$, \quad 
Wartości własne:$ \left\{ 1 : 2, \  -1 + \sqrt{10} : 1, \  - \sqrt{10} - 1 : 1\right\}, $\\
\parbox{4em}{Wektory\\własne:} $\left[ \left( 1, \  2, \  \left[ \left[\begin{matrix}0\\1\\0\\0\end{matrix}\right], \  \left[\begin{matrix}-1\\0\\0\\1\end{matrix}\right]\right]\right), \  \left( -1 + \sqrt{10}, \  1, \  \left[ \left[\begin{matrix}- \frac{8 \sqrt{10}}{43} - \frac{9}{43}\\\frac{6 \sqrt{10}}{43} + \frac{39}{43}\\- \frac{6}{43} + \frac{9 \sqrt{10}}{43}\\1\end{matrix}\right]\right]\right), \  \left( - \sqrt{10} - 1, \  1, \  \left[ \left[\begin{matrix}- \frac{9}{43} + \frac{8 \sqrt{10}}{43}\\\frac{39}{43} - \frac{6 \sqrt{10}}{43}\\- \frac{9 \sqrt{10}}{43} - \frac{6}{43}\\1\end{matrix}\right]\right]\right)\right]$,\\
$A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}0 & -1 & - \frac{8 \sqrt{10}}{43} - \frac{9}{43} & - \frac{9}{43} + \frac{8 \sqrt{10}}{43}\\1 & 0 & \frac{6 \sqrt{10}}{43} + \frac{39}{43} & \frac{39}{43} - \frac{6 \sqrt{10}}{43}\\0 & 0 & - \frac{6}{43} + \frac{9 \sqrt{10}}{43} & - \frac{9 \sqrt{10}}{43} - \frac{6}{43}\\0 & 1 & 1 & 1\end{matrix}\right],$ \quad 
$D=\left[\begin{matrix}1 & 0 & 0 & 0\\0 & 1 & 0 & 0\\0 & 0 & -1 + \sqrt{10} & 0\\0 & 0 & 0 & - \sqrt{10} - 1\end{matrix}\right]$
***********************************************************************************************
Hide code cell source
from random import choice

for i in range(1, ile_zadan_przykladowych):
    zadanie = gz.diagonalizacja_macierzy_z_wielokrotnym_wartosciami_wlasnymi(wymiar=choice([2, 3, 4]))
    print(f"\033[34m** Zadanie {i} **" + '*' * 80 + '\033[0m')
    display(Markdown(zadanie[0][:39]))
    display(Latex(zadanie[0][39:]))
    print("\033[34m*\033[0m" * 95)
    print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
    display(Latex(zadanie[1].split(', \quad')[0].replace("$", "$$")))
    display(Markdown("Wartości własne"))
    display(Latex("$$" + (zadanie[1].split(', \quad')[1]).split("$")[1] + "$$"))
    display(Markdown("Wektory własne"))
    display(Latex("$$" + (zadanie[1].split(', \quad')[1]).split("$")[3] + "$$"))
    display(Markdown("Diagonalizacja:"))
    try:
        display(Latex("$$" + (zadanie[1].split(', \quad')[1]).split("$")[5]
                      + '\quad ' + (zadanie[1].split(', \quad')[1]).split("$")[7] + "$$"))
    except Exception:
        display(Markdown("Macierz nie jest diagonalizowalna"))
    print("\033[32m*\033[0m" * 95)
** Zadanie 1 **********************************************************************************

Przeprowadzić diagonalizację macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}1 & 0 & 0 & 0\\1 & 1 & 0 & -2\\-1 & -2 & -2 & -1\\2 & 2 & 3 & 0\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} + 4 \lambda^{2} - 12 \lambda + 7\]

Wartości własne

\[ \left\{ 1 : 2, \ -1 - \sqrt{6} i : 1, \ -1 + \sqrt{6} i : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 1, \ 2, \ \left[ \left[\begin{matrix}0\\- \frac{3}{2}\\1\\0\end{matrix}\right], \ \left[\begin{matrix}2\\- \frac{3}{2}\\0\\1\end{matrix}\right]\right]\right), \ \left( -1 - \sqrt{6} i, \ 1, \ \left[ \left[\begin{matrix}0\\\frac{2}{5} - \frac{\sqrt{6} i}{5}\\- \frac{3}{5} - \frac{\sqrt{6} i}{5}\\1\end{matrix}\right]\right]\right), \ \left( -1 + \sqrt{6} i, \ 1, \ \left[ \left[\begin{matrix}0\\\frac{2}{5} + \frac{\sqrt{6} i}{5}\\- \frac{3}{5} + \frac{\sqrt{6} i}{5}\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}0 & 4 & 0 & 0\\-3 & -3 & \frac{2}{5} - \frac{\sqrt{6} i}{5} & \frac{2}{5} + \frac{\sqrt{6} i}{5}\\2 & 0 & - \frac{3}{5} - \frac{\sqrt{6} i}{5} & - \frac{3}{5} + \frac{\sqrt{6} i}{5}\\0 & 2 & 1 & 1\end{matrix}\right],\quad D=\left[\begin{matrix}1 & 0 & 0 & 0\\0 & 1 & 0 & 0\\0 & 0 & -1 - \sqrt{6} i & 0\\0 & 0 & 0 & -1 + \sqrt{6} i\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 2 **********************************************************************************

Przeprowadzić diagonalizację macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}0 & -1 & 1\\0 & -2 & 2\\0 & 2 & -2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{3} + 4 \lambda^{2}\]

Wartości własne

\[ \left\{ -4 : 1, \ 0 : 2\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( -4, \ 1, \ \left[ \left[\begin{matrix}- \frac{1}{2}\\-1\\1\end{matrix}\right]\right]\right), \ \left( 0, \ 2, \ \left[ \left[\begin{matrix}1\\0\\0\end{matrix}\right], \ \left[\begin{matrix}0\\1\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}-1 & 1 & 0\\-2 & 0 & 1\\2 & 0 & 1\end{matrix}\right],\quad D=\left[\begin{matrix}-4 & 0 & 0\\0 & 0 & 0\\0 & 0 & 0\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 3 **********************************************************************************

Przeprowadzić diagonalizację macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}1 & 0\\0 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - 2 \lambda + 1\]

Wartości własne

\[ \left\{ 1 : 2\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 1, \ 2, \ \left[ \left[\begin{matrix}1\\0\end{matrix}\right], \ \left[\begin{matrix}0\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}1 & 0\\0 & 1\end{matrix}\right],\quad D=\left[\begin{matrix}1 & 0\\0 & 1\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 4 **********************************************************************************

Przeprowadzić diagonalizację macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}3 & 0\\0 & 3\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - 6 \lambda + 9\]

Wartości własne

\[ \left\{ 3 : 2\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 3, \ 2, \ \left[ \left[\begin{matrix}1\\0\end{matrix}\right], \ \left[\begin{matrix}0\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}1 & 0\\0 & 1\end{matrix}\right],\quad D=\left[\begin{matrix}3 & 0\\0 & 3\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 5 **********************************************************************************

Przeprowadzić diagonalizację macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}0 & 0\\0 & 0\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2}\]

Wartości własne

\[ \left\{ 0 : 2\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 0, \ 2, \ \left[ \left[\begin{matrix}1\\0\end{matrix}\right], \ \left[\begin{matrix}0\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}1 & 0\\0 & 1\end{matrix}\right],\quad D=\left[\begin{matrix}0 & 0\\0 & 0\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 6 **********************************************************************************

Przeprowadzić diagonalizację macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}1 & 3 & 2 & 1\\-2 & -2 & -1 & -1\\1 & 3 & 2 & 1\\0 & 0 & 0 & 0\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} - \lambda^{3} + 3 \lambda^{2}\]

Wartości własne

\[ \left\{ 0 : 2, \ \frac{1}{2} - \frac{\sqrt{11} i}{2} : 1, \ \frac{1}{2} + \frac{\sqrt{11} i}{2} : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 0, \ 2, \ \left[ \left[\begin{matrix}\frac{1}{4}\\- \frac{3}{4}\\1\\0\end{matrix}\right], \ \left[\begin{matrix}- \frac{1}{4}\\- \frac{1}{4}\\0\\1\end{matrix}\right]\right]\right), \ \left( \frac{1}{2} - \frac{\sqrt{11} i}{2}, \ 1, \ \left[ \left[\begin{matrix}1\\- \frac{5}{6} - \frac{\sqrt{11} i}{6}\\1\\0\end{matrix}\right]\right]\right), \ \left( \frac{1}{2} + \frac{\sqrt{11} i}{2}, \ 1, \ \left[ \left[\begin{matrix}1\\- \frac{5}{6} + \frac{\sqrt{11} i}{6}\\1\\0\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}1 & -1 & 1 & 1\\-3 & -1 & - \frac{5}{6} - \frac{\sqrt{11} i}{6} & - \frac{5}{6} + \frac{\sqrt{11} i}{6}\\4 & 0 & 1 & 1\\0 & 4 & 0 & 0\end{matrix}\right],\quad D=\left[\begin{matrix}0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & \frac{1}{2} - \frac{\sqrt{11} i}{2} & 0\\0 & 0 & 0 & \frac{1}{2} + \frac{\sqrt{11} i}{2}\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 7 **********************************************************************************

Przeprowadzić diagonalizację macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}3 & 0 & 1\\0 & 3 & 0\\0 & 0 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{3} - 7 \lambda^{2} + 15 \lambda - 9\]

Wartości własne

\[ \left\{ 1 : 1, \ 3 : 2\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 1, \ 1, \ \left[ \left[\begin{matrix}- \frac{1}{2}\\0\\1\end{matrix}\right]\right]\right), \ \left( 3, \ 2, \ \left[ \left[\begin{matrix}1\\0\\0\end{matrix}\right], \ \left[\begin{matrix}0\\1\\0\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}-1 & 1 & 0\\0 & 0 & 1\\2 & 0 & 0\end{matrix}\right],\quad D=\left[\begin{matrix}1 & 0 & 0\\0 & 3 & 0\\0 & 0 & 3\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 8 **********************************************************************************

Przeprowadzić diagonalizację macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}2 & -2 & 1 & 1\\2 & -2 & 1 & 1\\2 & -2 & 1 & 3\\0 & 0 & 0 & -2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} + \lambda^{3} - 2 \lambda^{2}\]

Wartości własne

\[ \left\{ -2 : 1, \ 0 : 2, \ 1 : 1\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( -2, \ 1, \ \left[ \left[\begin{matrix}0\\0\\-1\\1\end{matrix}\right]\right]\right), \ \left( 0, \ 2, \ \left[ \left[\begin{matrix}1\\1\\0\\0\end{matrix}\right], \ \left[\begin{matrix}- \frac{1}{2}\\0\\1\\0\end{matrix}\right]\right]\right), \ \left( 1, \ 1, \ \left[ \left[\begin{matrix}1\\1\\1\\0\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}0 & 1 & -1 & 1\\0 & 1 & 0 & 1\\-1 & 0 & 2 & 1\\1 & 0 & 0 & 0\end{matrix}\right],\quad D=\left[\begin{matrix}-2 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 0\\0 & 0 & 0 & 1\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 9 **********************************************************************************

Przeprowadzić diagonalizację macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}1 & 0\\0 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - 2 \lambda + 1\]

Wartości własne

\[ \left\{ 1 : 2\right\}, \]

Wektory własne

\[\begin{split}\left[ \left( 1, \ 2, \ \left[ \left[\begin{matrix}1\\0\end{matrix}\right], \ \left[\begin{matrix}0\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}1 & 0\\0 & 1\end{matrix}\right],\quad D=\left[\begin{matrix}1 & 0\\0 & 1\end{matrix}\right]\end{split}\]
***********************************************************************************************

Regresja liniowa i wielomianowa (tylko wielomian pierwszego i drugiego stopnia)

zadanie = gz.regresja(stopien=1, nr_zadania=1)
zadanie
('Wyznaczyć prostą regresji dla punktów \n\t\\[\n\t\t(0,-1),\\  (-1,0),\\  (2,-3),\\  (-4,3),\\  (-5,4).\n\t\\]',
 '\t\\begin{tabular}{p{0.5\\textwidth}p{0.3\\textwidth}}\n\t\\vspace{0pt}\n\t\\[\n\t\t\\left[\\begin{matrix}0 & 1\\\\-1 & 1\\\\2 & 1\\\\-4 & 1\\\\-5 & 1\\end{matrix}\\right]\n\t\t\\cdot \\left[\\begin{matrix} a \\\\ b \\end{matrix}\\right]\n\t\t\\simeq \\left[\\begin{matrix}-1\\\\0\\\\-3\\\\3\\\\4\\end{matrix}\\right]\n\t\t\\quad \\Biggm/ \\cdot \\left(\\left(A^T A \\right)^{-1} A^T \\right)_L\n\t\\]\n\t\\[\n\t\t \\left[\\begin{matrix} a \\\\ b \\end{matrix}\\right] = \n\t\t \\left[\\begin{matrix} -1 \\\\ -1 \\end{matrix}\\right]\n\t\\]\n\t&\n\t\t\\raisebox{-4.9cm}{\\resizebox{5.2cm}{!}{\\includegraphics{../pics/regresja1}}}\n\t\\end{tabular}\n')
Hide code cell source
print("\033[34m** Zadanie **" + '*' * 81 + '\033[0m')
print(zadanie[0])
print("\033[34m*\033[0m" * 95)
print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
print(zadanie[1])
print("\033[32m*\033[0m" * 95)
** Zadanie ***********************************************************************************
Wyznaczyć prostą regresji dla punktów 
	\[
		(0,-1),\  (-1,0),\  (2,-3),\  (-4,3),\  (-5,4).
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
	\begin{tabular}{p{0.5\textwidth}p{0.3\textwidth}}
	\vspace{0pt}
	\[
		\left[\begin{matrix}0 & 1\\-1 & 1\\2 & 1\\-4 & 1\\-5 & 1\end{matrix}\right]
		\cdot \left[\begin{matrix} a \\ b \end{matrix}\right]
		\simeq \left[\begin{matrix}-1\\0\\-3\\3\\4\end{matrix}\right]
		\quad \Biggm/ \cdot \left(\left(A^T A \right)^{-1} A^T \right)_L
	\]
	\[
		 \left[\begin{matrix} a \\ b \end{matrix}\right] = 
		 \left[\begin{matrix} -1 \\ -1 \end{matrix}\right]
	\]
	&
		\raisebox{-4.9cm}{\resizebox{5.2cm}{!}{\includegraphics{../pics/regresja1}}}
	\end{tabular}

***********************************************************************************************
Hide code cell source
for i in range(1, ile_zadan_przykladowych + 1):
    zadanie = gz.regresja(stopien=choice([1, 2]), nr_zadania=i)
    print(f"\033[34m** Zadanie {i} **" + '*' * 80 + '\033[0m')
    display(Markdown(zadanie[0].split('\n')[0].replace('\\', '')))
    display(Latex('$$' + zadanie[0].split('\[')[1].split('\]')[0] + '$$'))
    print("\033[34m*\033[0m" * 95)
    print("\033[32m** Rozwiązanie **" + '*' * 78 + '\033[0m')
    temp = zadanie[1].split('_L')[0].split('[\n\t\t')[1] + '_L'
    display(Latex(f'$${temp}$$'))
    display(Latex(f"$${zadanie[1].split('_L')[1][12:].split('raisebox')[0][:-11]}$$"))
    display(Markdown(f'![](./pics//regresja{i}.png)'))
    # display(Markdown(f"<img src=./pics//regresja{i}.png width='350'>"))
    print("\033[32m*\033[0m" * 95)
** Zadanie 1 **********************************************************************************

Wyznaczyć prostą regresji dla punktów

\[ (1,1),\ (-2,5),\ (-5,4),\ (5,-3),\ (2,-2). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}1 & 1\\-2 & 1\\-5 & 1\\5 & 1\\2 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \end{matrix}\right] \simeq \left[\begin{matrix}1\\5\\4\\-3\\-2\end{matrix}\right] \quad \Biggm/ \cdot \left(\left(A^T A \right)^{-1} A^T \right)_L\end{split}\]
\[\begin{split}\left[\begin{matrix} a \\ b \end{matrix}\right] = \left[\begin{matrix} - \frac{5}{6} \\ \frac{7}{6} \end{matrix}\right]\end{split}\]

***********************************************************************************************
** Zadanie 2 **********************************************************************************

Wyznaczyć trójmian kwadratowy regresji dla punktów

\[ (-1,2),\ (1,0),\ (-2,1),\ (-4,-5),\ (2,-3). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}1 & -1 & 1\\1 & 1 & 1\\4 & -2 & 1\\16 & -4 & 1\\4 & 2 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \\ c \end{matrix}\right] \simeq \left[\begin{matrix}2\\0\\1\\-5\\-3\end{matrix}\right] \quad \Biggm/ \cdot \left(\left(A^T A \right)^{-1} A^T \right)_L\end{split}\]
\[\begin{split}\left[\begin{matrix} a \\ b \\ c \end{matrix}\right] = \left[\begin{matrix} - \frac{2}{3} \\ -1 \\ \frac{5}{3} \end{matrix}\right]\end{split}\]

***********************************************************************************************
** Zadanie 3 **********************************************************************************

Wyznaczyć prostą regresji dla punktów

\[ (1,1),\ (5,-5),\ (-4,4),\ (3,-2),\ (0,2). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}1 & 1\\5 & 1\\-4 & 1\\3 & 1\\0 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \end{matrix}\right] \simeq \left[\begin{matrix}1\\-5\\4\\-2\\2\end{matrix}\right] \quad \Biggm/ \cdot \left(\left(A^T A \right)^{-1} A^T \right)_L\end{split}\]
\[\begin{split}\left[\begin{matrix} a \\ b \end{matrix}\right] = \left[\begin{matrix} -1 \\ 1 \end{matrix}\right]\end{split}\]

***********************************************************************************************
** Zadanie 4 **********************************************************************************

Wyznaczyć prostą regresji dla punktów

\[ (-1,2),\ (3,-5),\ (1,0),\ (4,-3),\ (-2,1). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}-1 & 1\\3 & 1\\1 & 1\\4 & 1\\-2 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \end{matrix}\right] \simeq \left[\begin{matrix}2\\-5\\0\\-3\\1\end{matrix}\right] \quad \Biggm/ \cdot \left(\left(A^T A \right)^{-1} A^T \right)_L\end{split}\]
\[\begin{split}\left[\begin{matrix} a \\ b \end{matrix}\right] = \left[\begin{matrix} -1 \\ 0 \end{matrix}\right]\end{split}\]

***********************************************************************************************
** Zadanie 5 **********************************************************************************

Wyznaczyć trójmian kwadratowy regresji dla punktów

\[ (1,4),\ (-4,-4),\ (-3,-1),\ (2,-3),\ (0,5). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}1 & 1 & 1\\16 & -4 & 1\\9 & -3 & 1\\4 & 2 & 1\\0 & 0 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \\ c \end{matrix}\right] \simeq \left[\begin{matrix}4\\-4\\-1\\-3\\5\end{matrix}\right] \quad \Biggm/ \cdot \left(\left(A^T A \right)^{-1} A^T \right)_L\end{split}\]
\[\begin{split}\left[\begin{matrix} a \\ b \\ c \end{matrix}\right] = \left[\begin{matrix} -1 \\ - \frac{3}{2} \\ 5 \end{matrix}\right]\end{split}\]

***********************************************************************************************
** Zadanie 6 **********************************************************************************

Wyznaczyć trójmian kwadratowy regresji dla punktów

\[ (3,-4),\ (4,-5),\ (1,-2),\ (-3,2),\ (0,-1). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}9 & 3 & 1\\16 & 4 & 1\\1 & 1 & 1\\9 & -3 & 1\\0 & 0 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \\ c \end{matrix}\right] \simeq \left[\begin{matrix}-4\\-5\\-2\\2\\-1\end{matrix}\right] \quad \Biggm/ \cdot \left(\left(A^T A \right)^{-1} A^T \right)_L\end{split}\]
\[\begin{split}\left[\begin{matrix} a \\ b \\ c \end{matrix}\right] = \left[\begin{matrix} 0 \\ -1 \\ -1 \end{matrix}\right]\end{split}\]

***********************************************************************************************
** Zadanie 7 **********************************************************************************

Wyznaczyć prostą regresji dla punktów

\[ (3,-2),\ (1,-4),\ (2,-3),\ (4,-1),\ (0,-5). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}3 & 1\\1 & 1\\2 & 1\\4 & 1\\0 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \end{matrix}\right] \simeq \left[\begin{matrix}-2\\-4\\-3\\-1\\-5\end{matrix}\right] \quad \Biggm/ \cdot \left(\left(A^T A \right)^{-1} A^T \right)_L\end{split}\]
\[\begin{split}\left[\begin{matrix} a \\ b \end{matrix}\right] = \left[\begin{matrix} 1 \\ -5 \end{matrix}\right]\end{split}\]

***********************************************************************************************
** Zadanie 8 **********************************************************************************

Wyznaczyć prostą regresji dla punktów

\[ (-3,3),\ (4,-2),\ (3,1),\ (1,2),\ (-2,4). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}-3 & 1\\4 & 1\\3 & 1\\1 & 1\\-2 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \end{matrix}\right] \simeq \left[\begin{matrix}3\\-2\\1\\2\\4\end{matrix}\right] \quad \Biggm/ \cdot \left(\left(A^T A \right)^{-1} A^T \right)_L\end{split}\]
\[\begin{split}\left[\begin{matrix} a \\ b \end{matrix}\right] = \left[\begin{matrix} - \frac{2}{3} \\ 2 \end{matrix}\right]\end{split}\]

***********************************************************************************************
** Zadanie 9 **********************************************************************************

Wyznaczyć trójmian kwadratowy regresji dla punktów

\[ (-4,2),\ (-3,0),\ (-1,-4),\ (2,1),\ (0,-5). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}16 & -4 & 1\\9 & -3 & 1\\1 & -1 & 1\\4 & 2 & 1\\0 & 0 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \\ c \end{matrix}\right] \simeq \left[\begin{matrix}2\\0\\-4\\1\\-5\end{matrix}\right] \quad \Biggm/ \cdot \left(\left(A^T A \right)^{-1} A^T \right)_L\end{split}\]
\[\begin{split}\left[\begin{matrix} a \\ b \\ c \end{matrix}\right] = \left[\begin{matrix} \frac{2}{3} \\ 1 \\ -4 \end{matrix}\right]\end{split}\]

***********************************************************************************************
** Zadanie 10 **********************************************************************************

Wyznaczyć prostą regresji dla punktów

\[ (1,3),\ (0,4),\ (-2,1),\ (-5,0),\ (-4,2). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}1 & 1\\0 & 1\\-2 & 1\\-5 & 1\\-4 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \end{matrix}\right] \simeq \left[\begin{matrix}3\\4\\1\\0\\2\end{matrix}\right] \quad \Biggm/ \cdot \left(\left(A^T A \right)^{-1} A^T \right)_L\end{split}\]
\[\begin{split}\left[\begin{matrix} a \\ b \end{matrix}\right] = \left[\begin{matrix} \frac{1}{2} \\ 3 \end{matrix}\right]\end{split}\]

***********************************************************************************************