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.10
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}-1 & 0 & 0 & 3 & 1\\\\1 & -2 & 3 & -1 & 0\\\\0 & -1 & -2 & 3 & 3\\\\3 & -2 & 0 & 0 & 1\\\\-2 & -2 & 2 & -2 & 2\\end{matrix}\\right]\n\t\\]',
 '$\\det(A)= 0$')
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}-1 & 0 & 0 & 3 & 1\\1 & -2 & 3 & -1 & 0\\0 & -1 & -2 & 3 & 3\\3 & -2 & 0 & 0 & 1\\-2 & -2 & 2 & -2 & 2\end{matrix}\right]
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$\det(A)= 0$
***********************************************************************************************
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}-2 & 1 & -1 & -1 & -2 & 0\\-1 & -2 & 1 & 2 & -2 & 0\\3 & 2 & 3 & 1 & 3 & 3\\-2 & -1 & 2 & -1 & -1 & -2\\0 & -1 & 2 & 2 & 0 & 1\\-1 & 2 & -1 & 0 & -2 & 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det(A)= 0\]
***********************************************************************************************
** Zadanie 2 **********************************************************************************

Obliczyć wyznacznik macierzy A

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

Obliczyć wyznacznik macierzy A

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

Obliczyć wyznacznik macierzy A

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

Obliczyć wyznacznik macierzy A

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

Obliczyć wyznacznik macierzy A

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

Obliczyć wyznacznik macierzy A

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

Obliczyć wyznacznik macierzy A

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

Obliczyć wyznacznik macierzy A

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

Obliczyć wyznacznik macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}0 & 3 & 2 & 0 & -1 & -2\\1 & 3 & 1 & 1 & 3 & -1\\3 & 2 & -2 & 3 & 1 & -2\\0 & -2 & -2 & 0 & 1 & -1\\-2 & 1 & 1 & -2 & -1 & 3\\3 & 1 & 2 & 3 & 1 & 0\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 & 2 & -1 & -1 & -1\\\\-1 & 1 & 1 & 0 & 1\\end{matrix}\\right]\\cdot \n\t\t\\left[\\begin{matrix}-2 & -1 & 1 & -2 & 1\\\\1 & 0 & 0 & 1 & 0\\end{matrix}\\right]^T + \n\t\t2X=\n\t\tX \\cdot \\left[\\begin{matrix}0 & 0\\\\0 & 0\\\\1 & -1\\\\-1 & -1\\\\2 & 0\\end{matrix}\\right]^T \\cdot\n\t\t\\left[\\begin{matrix}-1 & 0\\\\-2 & -2\\\\-2 & 1\\\\1 & -1\\\\1 & 0\\end{matrix}\\right] \n\t\\]',
 '$ \\left[\\begin{matrix}0 & -2\\\\3 & -1\\end{matrix}\\right] + \n\t2X=\n\tX \\cdot \\left[\\begin{matrix}-1 & 2\\\\1 & 0\\end{matrix}\\right] , \\quad \n\t\\left[\\begin{matrix}0 & -2\\\\3 & -1\\end{matrix}\\right] = \n\tX \\cdot \\left[\\begin{matrix}-3 & 2\\\\1 & -2\\end{matrix}\\right] $ \\\\ \n\t$X=\\frac{1}{4}\\left[\\begin{matrix}2 & 6\\\\-5 & -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 ***********************************************************************************
Rozwiązać równanie:
	\[
		\left[\begin{matrix}-1 & 2 & -1 & -1 & -1\\-1 & 1 & 1 & 0 & 1\end{matrix}\right]\cdot 
		\left[\begin{matrix}-2 & -1 & 1 & -2 & 1\\1 & 0 & 0 & 1 & 0\end{matrix}\right]^T + 
		2X=
		X \cdot \left[\begin{matrix}0 & 0\\0 & 0\\1 & -1\\-1 & -1\\2 & 0\end{matrix}\right]^T \cdot
		\left[\begin{matrix}-1 & 0\\-2 & -2\\-2 & 1\\1 & -1\\1 & 0\end{matrix}\right] 
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$ \left[\begin{matrix}0 & -2\\3 & -1\end{matrix}\right] + 
	2X=
	X \cdot \left[\begin{matrix}-1 & 2\\1 & 0\end{matrix}\right] , \quad 
	\left[\begin{matrix}0 & -2\\3 & -1\end{matrix}\right] = 
	X \cdot \left[\begin{matrix}-3 & 2\\1 & -2\end{matrix}\right] $ \\ 
	$X=\frac{1}{4}\left[\begin{matrix}2 & 6\\-5 & -3\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}1 & 2 & 1 & 0 & 1\\1 & 1 & 0 & -1 & 0\end{matrix}\right]\cdot \left[\begin{matrix}0 & 1 & -1 & 0 & -2\\0 & -2 & 1 & -2 & -1\end{matrix}\right]^T + 3X= \left[\begin{matrix}0 & 0\\2 & 2\\0 & 2\\2 & -1\\0 & -1\end{matrix}\right]^T \cdot \left[\begin{matrix}0 & -2\\-2 & 0\\-1 & 1\\-2 & 1\\-2 & -2\end{matrix}\right] \cdot X \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split} \left[\begin{matrix}-1 & -4\\1 & 0\end{matrix}\right] + 3X= \left[\begin{matrix}-8 & 2\\-2 & 3\end{matrix}\right] \cdot X, \quad \left[\begin{matrix}-1 & -4\\1 & 0\end{matrix}\right] = \left[\begin{matrix}-11 & 2\\-2 & 0\end{matrix}\right] \cdot X ,\quad X=\frac{1}{4}\left[\begin{matrix}-2 & 0\\-13 & -8\end{matrix}\right].\end{split}\]
***********************************************************************************************
** Zadanie 2 **********************************************************************************

Rozwiązać równanie

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

Rozwiązać równanie

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

Rozwiązać równanie

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

Rozwiązać równanie

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

Rozwiązać równanie

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

Rozwiązać równanie

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

Rozwiązać równanie

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

Rozwiązać równanie

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

Rozwiązać równanie

\[\begin{split} \left[\begin{matrix}1 & -1 & 0 & 0 & -1\\-1 & 0 & 1 & -1 & -1\end{matrix}\right]\cdot \left[\begin{matrix}-2 & 0 & 1 & 0 & -1\\-1 & -1 & -2 & -1 & 1\end{matrix}\right]^T + 4X= \left[\begin{matrix}0 & 1\\1 & -1\\-1 & 1\\1 & -1\\0 & -1\end{matrix}\right]^T \cdot \left[\begin{matrix}1 & 1\\-1 & -2\\-2 & 1\\0 & 1\\1 & -1\end{matrix}\right] \cdot X \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split} \left[\begin{matrix}-1 & -1\\4 & -1\end{matrix}\right] + 4X= \left[\begin{matrix}1 & -2\\-1 & 4\end{matrix}\right] \cdot X, \quad \left[\begin{matrix}-1 & -1\\4 & -1\end{matrix}\right] = \left[\begin{matrix}-3 & -2\\-1 & 0\end{matrix}\right] \cdot X ,\quad X=\frac{1}{-2}\left[\begin{matrix}8 & -2\\-13 & 2\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}-2 & 2 & 0 & 2\\\\-4 & x - 4 & -2 & x - 3\\\\x + 3 & 3 & x & x - 1\\\\4 & -2 & 2 & 1\\end{matrix}\\right]\n\t\\]',
 '$\\det A=- 2 x^{2} - 4 x \\neq 0, \\quad x\\neq -2, \\ x\\neq 0, \\ $')
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}-2 & 2 & 0 & 2\\-4 & x - 4 & -2 & x - 3\\x + 3 & 3 & x & x - 1\\4 & -2 & 2 & 1\end{matrix}\right]
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$\det A=- 2 x^{2} - 4 x \neq 0, \quad x\neq -2, \ x\neq 0, \ $
***********************************************************************************************
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}-2 & -2 & 3 x - 2\\-3 & -1 & -1\\x - 1 & 1 & -2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=3 x^{2} - 12 x + 12 \neq 0, \quad x\neq 2, \ \]
***********************************************************************************************
** Zadanie 2 **********************************************************************************

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

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

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

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

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

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-4 & x + 2\\x - 4 & x + 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- x^{2} - 2 x \neq 0, \quad x\neq -2, \ x\neq 0, \ \]
***********************************************************************************************
** 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 + 4 & 2 & x - 2\\0 & 4 & x + 1\\x - 3 & 1 & 4\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- 3 x^{2} + 27 x + 30 \neq 0, \quad x\neq -1, \ x\neq 10, \ \]
***********************************************************************************************
** 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 & x - 1 & x + 1\\2 x - 3 & 4 & 1\\-1 & 1 & 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- 2 x^{2} + 12 x - 18 \neq 0, \quad x\neq 3, \ \]
***********************************************************************************************
** Zadanie 7 **********************************************************************************

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

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

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 & x - 4\\-1 & -1 & x + 4\\1 & 0 & x + 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- x^{2} + 6 x + 16 \neq 0, \quad x\neq -2, \ x\neq 8, \ \]
***********************************************************************************************
** Zadanie 9 **********************************************************************************

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

\[\begin{split} \textnormal{A=} \left[\begin{matrix}1 & -2 & x + 3 & 4\\3 & 1 & -2 & x\\4 & x - 1 & 1 & 4\\3 & x - 3 & x - 4 & 4\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=2 x^{3} - 16 x^{2} + 30 x \neq 0, \quad x\neq 0, \ x\neq 3, \ x\neq 5, \ \]
***********************************************************************************************
** 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 - 1 & x & 1\\-3 & -2 & 4\\-3 & x - 2 & x + 4\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- 3 x^{2} + 3 x \neq 0, \quad x\neq 0, \ x\neq 1, \ \]
***********************************************************************************************

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}-2 & x + 2\\\\x + 2 & 2 x + 4\\end{matrix}\\right]\n\t\\]\nWyznaczyć macierz odwrotną dla $x=-1.$ Wykonać sprawdzenie.\\\\',
 '$\\det A=- x^{2} - 8 x - 12\\neq 0, \\quad \n\tx\\neq -6\\ \\textnormal{oraz} \\ x\\neq -2,$\\\\\n\t$A(-1)= \\left[\\begin{matrix}-2 & 1\\\\1 & 2\\end{matrix}\\right],\\ \n\t\\det A(-1)=-5,\\ \n\tA^{-1}=- \\frac{1}{5}\\left[\\begin{matrix}2 & -1\\\\-1 & -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 ***********************************************************************************
Dla jakich rzeczywistych wartości parametru $x$ macierz $A$ posiada odwrotność?
	\[
		\textnormal{A=}\left[\begin{matrix}-2 & x + 2\\x + 2 & 2 x + 4\end{matrix}\right]
	\]
Wyznaczyć macierz odwrotną dla $x=-1.$ Wykonać sprawdzenie.\\
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$\det A=- x^{2} - 8 x - 12\neq 0, \quad 
	x\neq -6\ \textnormal{oraz} \ x\neq -2,$\\
	$A(-1)= \left[\begin{matrix}-2 & 1\\1 & 2\end{matrix}\right],\ 
	\det A(-1)=-5,\ 
	A^{-1}=- \frac{1}{5}\left[\begin{matrix}2 & -1\\-1 & -2\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 & 1 & 2\\2 x - 2 & 2 & x - 1\\-4 & x - 4 & 2\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=2.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=2 x^{2} - 18 x + 40\neq 0, \quad x\neq 4\ \textnormal{oraz} \ x\neq 5, \]
\[\begin{split} A(2)= \left[\begin{matrix}2 & 1 & 2\\2 & 2 & 1\\-4 & -2 & 2\end{matrix}\right],\ \det A(2)=12,\ A^{-1}=\frac{1}{12}\left[\begin{matrix}6 & -6 & -3\\-8 & 12 & 2\\4 & 0 & 2\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}4 & -2 & 2 & 1\\4 & 2 & x + 3 & -1\\-3 & 2 x + 2 & 2 & -3\\-1 & -2 & x + 4 & -2\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=3.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=2 - 2 x^{2}\neq 0, \quad x\neq -1\ \textnormal{oraz} \ x\neq 1, \]
\[\begin{split} A(3)= \left[\begin{matrix}4 & -2 & 2 & 1\\4 & 2 & 6 & -1\\-3 & 8 & 2 & -3\\-1 & -2 & 7 & -2\end{matrix}\right],\ \det A(3)=-16,\ A^{-1}=- \frac{1}{16}\left[\begin{matrix}106 & -70 & 48 & 16\\-69 & 43 & -32 & -8\\-108 & 68 & -48 & -16\\-362 & 230 & -160 & -48\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}x - 1 & 4 & x + 3 & x + 1\\3 & 1 & x + 2 & 3\\4 & 0 & 2 & 2\\-3 & 1 & -1 & 0\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=3.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- 2 x^{2} + 18 x\neq 0, \quad x\neq 0\ \textnormal{oraz} \ x\neq 9, \]
\[\begin{split} A(3)= \left[\begin{matrix}2 & 4 & 6 & 4\\3 & 1 & 5 & 3\\4 & 0 & 2 & 2\\-3 & 1 & -1 & 0\end{matrix}\right],\ \det A(3)=36,\ A^{-1}=\frac{1}{36}\left[\begin{matrix}6 & -12 & 6 & -12\\18 & -24 & 0 & -12\\0 & 12 & -18 & -12\\-12 & 12 & 24 & 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}4 & 4 & 0 & x - 3\\-3 & -2 & -2 & x + 4\\2 & 2 & x + 1 & x\\-2 & -2 & 4 & 3\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=-2.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=2 x^{2} - 18\neq 0, \quad x\neq -3\ \textnormal{oraz} \ x\neq 3, \]
\[\begin{split} A(-2)= \left[\begin{matrix}4 & 4 & 0 & -5\\-3 & -2 & -2 & 2\\2 & 2 & -1 & -2\\-2 & -2 & 4 & 3\end{matrix}\right],\ \det A(-2)=-10,\ A^{-1}=- \frac{1}{10}\left[\begin{matrix}6 & 10 & 4 & 6\\-1 & -10 & -24 & -11\\-2 & 0 & 2 & -2\\6 & 0 & -16 & -4\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}-3 & 2 & 2 & -4\\0 & 1 & -1 & -1\\-3 & -3 & x - 1 & -1\\x - 3 & x - 4 & x - 2 & 1\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=2.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- x^{2} - 9 x + 36\neq 0, \quad x\neq -12\ \textnormal{oraz} \ x\neq 3, \]
\[\begin{split} A(2)= \left[\begin{matrix}-3 & 2 & 2 & -4\\0 & 1 & -1 & -1\\-3 & -3 & 1 & -1\\-1 & -2 & 0 & 1\end{matrix}\right],\ \det A(2)=14,\ A^{-1}=\frac{1}{14}\left[\begin{matrix}-6 & -4 & 8 & -20\\5 & 1 & -9 & 12\\1 & -11 & 1 & -6\\4 & -2 & -10 & 18\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}x + 3 & x + 4 & -4\\3 & x - 4 & -3\\4 & x - 3 & -4\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=3.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- x^{2} + 8 x - 7\neq 0, \quad x\neq 1\ \textnormal{oraz} \ x\neq 7, \]
\[\begin{split} A(3)= \left[\begin{matrix}6 & 7 & -4\\3 & -1 & -3\\4 & 0 & -4\end{matrix}\right],\ \det A(3)=8,\ A^{-1}=\frac{1}{8}\left[\begin{matrix}4 & 28 & -25\\0 & -8 & 6\\4 & 28 & -27\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 - 1 & -1 & -2 & 4\\1 & -1 & -2 & 2\\x - 3 & x + 2 & -2 & x - 3\\1 & 2 & 1 & 2\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=2.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=3 x^{2} + 27 x - 108\neq 0, \quad x\neq -12\ \textnormal{oraz} \ x\neq 3, \]
\[\begin{split} A(2)= \left[\begin{matrix}1 & -1 & -2 & 4\\1 & -1 & -2 & 2\\-1 & 4 & -2 & -1\\1 & 2 & 1 & 2\end{matrix}\right],\ \det A(2)=-42,\ A^{-1}=- \frac{1}{42}\left[\begin{matrix}39 & -55 & 6 & -20\\3 & -1 & -6 & -8\\-3 & 15 & 6 & -6\\-21 & 21 & 0 & 0\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}x + 4 & x + 2 & x - 2\\2 & 2 & x + 2\\-2 & -1 & 2\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=3.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=4 - x^{2}\neq 0, \quad x\neq -2\ \textnormal{oraz} \ x\neq 2, \]
\[\begin{split} A(3)= \left[\begin{matrix}7 & 5 & 1\\2 & 2 & 5\\-2 & -1 & 2\end{matrix}\right],\ \det A(3)=-5,\ A^{-1}=- \frac{1}{5}\left[\begin{matrix}9 & -11 & 23\\-14 & 16 & -33\\2 & -3 & 4\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}x - 1 & 2 & 2 x - 1\\2 & -1 & x - 3\\-4 & 2 & -2\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=-1.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- 2 x^{2} + 2 x + 24\neq 0, \quad x\neq -3\ \textnormal{oraz} \ x\neq 4, \]
\[\begin{split} A(-1)= \left[\begin{matrix}-2 & 2 & -3\\2 & -1 & -4\\-4 & 2 & -2\end{matrix}\right],\ \det A(-1)=20,\ A^{-1}=\frac{1}{20}\left[\begin{matrix}10 & -2 & -11\\20 & -8 & -14\\0 & -4 & -2\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}x + 4 & -1 & 2 x - 1\\2 & -2 & x + 1\\-3 & 1 & -1\end{matrix}\right] \end{split}\]

Wyznaczyć macierz odwrotną dla x=-1.

***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det A=- x^{2} - 8 x + 9\neq 0, \quad x\neq -9\ \textnormal{oraz} \ x\neq 1, \]
\[\begin{split} A(-1)= \left[\begin{matrix}3 & -1 & -3\\2 & -2 & 0\\-3 & 1 & -1\end{matrix}\right],\ \det A(-1)=16,\ A^{-1}=\frac{1}{16}\left[\begin{matrix}2 & -4 & -6\\2 & -12 & -6\\-4 & 0 & -4\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}-1 & 0 & 0 & 0\\\\-2 & -2 & 2 & 0\\\\1 & 1 & -1 & -1\\\\3 & -1 & 1 & -1\\end{matrix}\\right]\n\t\\]',
 '$\\det\\left(\\lambda \\mathbb{I} - A \\right) = \\lambda^{4} + 5 \\lambda^{3} + 8 \\lambda^{2} + 4 \\lambda$, \\quad \nWartości własne:$ \\left\\{ -2 : 2, \\  -1 : 1, \\  0 : 1\\right\\}, $\\\\\n\t\\parbox{4em}{Wektory\\\\własne:} $\\left[ \\left( -2, \\  2, \\  \\left[ \\left[\\begin{matrix}0\\\\1\\\\0\\\\1\\end{matrix}\\right]\\right]\\right), \\  \\left( -1, \\  1, \\  \\left[ \\left[\\begin{matrix}\\frac{1}{9}\\\\\\frac{8}{9}\\\\\\frac{5}{9}\\\\1\\end{matrix}\\right]\\right]\\right), \\  \\left( 0, \\  1, \\  \\left[ \\left[\\begin{matrix}0\\\\1\\\\1\\\\0\\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}-1 & 0 & 0 & 0\\-2 & -2 & 2 & 0\\1 & 1 & -1 & -1\\3 & -1 & 1 & -1\end{matrix}\right]
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} + 5 \lambda^{3} + 8 \lambda^{2} + 4 \lambda$, \quad 
Wartości własne:$ \left\{ -2 : 2, \  -1 : 1, \  0 : 1\right\}, $\\
	\parbox{4em}{Wektory\\własne:} $\left[ \left( -2, \  2, \  \left[ \left[\begin{matrix}0\\1\\0\\1\end{matrix}\right]\right]\right), \  \left( -1, \  1, \  \left[ \left[\begin{matrix}\frac{1}{9}\\\frac{8}{9}\\\frac{5}{9}\\1\end{matrix}\right]\right]\right), \  \left( 0, \  1, \  \left[ \left[\begin{matrix}0\\1\\1\\0\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\\0 & -1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - 2 \lambda - 3\]

Wartości własne

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

Wektory własne

\[\begin{split}\left[ \left( -1, \ 1, \ \left[ \left[\begin{matrix}\frac{1}{2}\\1\end{matrix}\right]\right]\right), \ \left( 3, \ 1, \ \left[ \left[\begin{matrix}1\\0\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 & 3\\0 & -1 & 0\\0 & 3 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{3} - \lambda^{2} - \lambda + 1\]

Wartości własne

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

Wektory własne

\[\begin{split}\left[ \left( -1, \ 1, \ \left[ \left[\begin{matrix}- \frac{11}{6}\\- \frac{2}{3}\\1\end{matrix}\right]\right]\right), \ \left( 1, \ 2, \ \left[ \left[\begin{matrix}1\\0\\0\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}1 & 3\\0 & -1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - 1\]

Wartości własne

\[ \left\{ -1 : 1, \ 1 : 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( 1, \ 1, \ \left[ \left[\begin{matrix}1\\0\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 & -1 & -1\\2 & -1 & -1\\3 & 2 & 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{3} - 4 \lambda^{2} + 8 \lambda\]

Wartości własne

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

Wektory własne

\[\begin{split}\left[ \left( 0, \ 1, \ \left[ \left[\begin{matrix}0\\-1\\1\end{matrix}\right]\right]\right), \ \left( 2 - 2 i, \ 1, \ \left[ \left[\begin{matrix}\frac{2}{41} - \frac{18 i}{41}\\- \frac{3}{41} - \frac{14 i}{41}\\1\end{matrix}\right]\right]\right), \ \left( 2 + 2 i, \ 1, \ \left[ \left[\begin{matrix}\frac{2}{41} + \frac{18 i}{41}\\- \frac{3}{41} + \frac{14 i}{41}\\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 & 3 & 0 & 0\\3 & 0 & 1 & -1\\-1 & -1 & -1 & 2\\-1 & -1 & 1 & 0\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} + \lambda^{3} - 11 \lambda^{2} - 9 \lambda + 18\]

Wartości własne

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

Wektory własne

\[\begin{split}\left[ \left( -3, \ 1, \ \left[ \left[\begin{matrix}-1\\1\\0\\0\end{matrix}\right]\right]\right), \ \left( -2, \ 1, \ \left[ \left[\begin{matrix}\frac{3}{2}\\-1\\- \frac{3}{2}\\1\end{matrix}\right]\right]\right), \ \left( 1, \ 1, \ \left[ \left[\begin{matrix}0\\0\\1\\1\end{matrix}\right]\right]\right), \ \left( 3, \ 1, \ \left[ \left[\begin{matrix}-1\\-1\\1\\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 & 3 & -1 & -2\\-1 & -2 & 2 & 0\\-1 & 1 & 3 & 2\\1 & 2 & -1 & 0\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} - 4 \lambda^{3} + \lambda^{2} + 6 \lambda\]

Wartości własne

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

Wektory własne

\[\begin{split}\left[ \left( -1, \ 1, \ \left[ \left[\begin{matrix}\frac{11}{8}\\- \frac{9}{8}\\\frac{1}{8}\\1\end{matrix}\right]\right]\right), \ \left( 0, \ 1, \ \left[ \left[\begin{matrix}\frac{4}{3}\\- \frac{2}{3}\\0\\1\end{matrix}\right]\right]\right), \ \left( 2, \ 1, \ \left[ \left[\begin{matrix}4\\0\\2\\1\end{matrix}\right]\right]\right), \ \left( 3, \ 1, \ \left[ \left[\begin{matrix}\frac{1}{3}\\\frac{1}{3}\\1\\0\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}3 & -1\\1 & 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - 5 \lambda + 7\]

Wartości własne

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

Wektory własne

\[\begin{split}\left[ \left( \frac{5}{2} - \frac{\sqrt{3} i}{2}, \ 1, \ \left[ \left[\begin{matrix}\frac{1}{2} - \frac{\sqrt{3} i}{2}\\1\end{matrix}\right]\right]\right), \ \left( \frac{5}{2} + \frac{\sqrt{3} i}{2}, \ 1, \ \left[ \left[\begin{matrix}\frac{1}{2} + \frac{\sqrt{3} 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}1 & 1\\1 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - 2 \lambda\]

Wartości własne

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

Wektory własne

\[\begin{split}\left[ \left( 0, \ 1, \ \left[ \left[\begin{matrix}-1\\1\end{matrix}\right]\right]\right), \ \left( 2, \ 1, \ \left[ \left[\begin{matrix}1\\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}-2 & -1 & 3\\-1 & 0 & 0\\-1 & -1 & 1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{3} + \lambda^{2} - 2\]

Wartości własne

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

Wektory własne

\[\begin{split}\left[ \left( 1, \ 1, \ \left[ \left[\begin{matrix}\frac{3}{2}\\- \frac{3}{2}\\1\end{matrix}\right]\right]\right), \ \left( -1 - i, \ 1, \ \left[ \left[\begin{matrix}1 + i\\1\\1\end{matrix}\right]\right]\right), \ \left( -1 + i, \ 1, \ \left[ \left[\begin{matrix}1 - i\\1\\1\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 & 0 & -1\\2 & 1 & 2 & 2\\2 & 2 & 1 & -2\\0 & 0 & -1 & -1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} - 3 \lambda^{3} - 11 \lambda^{2} + 3 \lambda + 10\]

Wartości własne

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

Wektory własne

\[\begin{split}\left[ \left( -2, \ 1, \ \left[ \left[\begin{matrix}\frac{5}{2}\\-3\\1\\1\end{matrix}\right]\right]\right), \ \left( -1, \ 1, \ \left[ \left[\begin{matrix}-1\\1\\0\\0\end{matrix}\right]\right]\right), \ \left( 1, \ 1, \ \left[ \left[\begin{matrix}1\\0\\-2\\1\end{matrix}\right]\right]\right), \ \left( 5, \ 1, \ \left[ \left[\begin{matrix}- \frac{17}{3}\\- \frac{16}{3}\\-6\\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 & -1 & 2 & 1 & 1 & 0\\\\-2 & -1 & -2 & 1 & 0 & 2\\\\-2 & -2 & 0 & 2 & 1 & 2\\\\-2 & 1 & -2 & 3 & 0 & -1\\end{matrix}\\right]\n\t\\]',
 '$R(A)= 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 ***********************************************************************************
Wyznaczyć rząd macierzy A
	\[
		\textnormal{A=} \left[\begin{matrix}0 & -1 & 2 & 1 & 1 & 0\\-2 & -1 & -2 & 1 & 0 & 2\\-2 & -2 & 0 & 2 & 1 & 2\\-2 & 1 & -2 & 3 & 0 & -1\end{matrix}\right]
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$R(A)= 3$
***********************************************************************************************
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 & -2 & 2\\1 & 1 & 0 & 1\\0 & 0 & 3 & 2\\-1 & -1 & 2 & -1\\3 & 3 & 3 & -1\\1 & 1 & 3 & 3\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\\0 & 0 & 0 & 2\\-1 & -2 & 1 & -2\\1 & 2 & -1 & -2\\-1 & -2 & 1 & -2\\-2 & -2 & -2 & -1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[R(A)= 3\]
***********************************************************************************************
** Zadanie 3 **********************************************************************************

Wyznaczyć rząd macierzy A

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

Wyznaczyć rząd macierzy A

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

Wyznaczyć rząd macierzy A

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

Wyznaczyć rząd macierzy A

\[\begin{split} \textnormal{A=} \left[\begin{matrix}1 & -2 & 2 & -1 & 0\\-2 & 3 & -2 & 1 & 0\\2 & -1 & 1 & -2 & 0\\-2 & 1 & 0 & 3 & 2\\-2 & -1 & 3 & 3 & 3\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 & 3 & 1 & -2\\0 & 0 & 3 & 0\\0 & 1 & 0 & 0\\0 & 2 & 0 & 0\\-1 & 1 & 2 & -1\\-1 & 1 & 3 & -1\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 & 0 & 3 & 1\\1 & 0 & 1 & 3 & -1 & 2\\0 & -1 & 1 & 1 & 3 & 2\\0 & 1 & 2 & -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}2 & 1 & 0 & -1 & 0\\1 & 0 & 0 & 0 & -1\\1 & 2 & -2 & 3 & 1\\0 & -2 & 1 & 0 & -2\\1 & -1 & 2 & -2 & 3\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[R(A)= 4\]
***********************************************************************************************

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}0 & 0 & 1 & -1\\\\0 & -1 & 0 & 1\\\\0 & 0 & 3 & -1\\\\0 & 0 & 0 & 3\\end{matrix}\\right]\n\t\\]',
 '$\\det\\left(\\lambda \\mathbb{I} - A \\right) = \\lambda^{4} - 5 \\lambda^{3} + 3 \\lambda^{2} + 9 \\lambda$, \\quad \nWartości własne:$ \\left\\{ -1 : 1, \\  0 : 1, \\  3 : 2\\right\\}, $\\\\\n\\parbox{4em}{Wektory\\\\własne:} $\\left[ \\left( -1, \\  1, \\  \\left[ \\left[\\begin{matrix}0\\\\1\\\\0\\\\0\\end{matrix}\\right]\\right]\\right), \\  \\left( 0, \\  1, \\  \\left[ \\left[\\begin{matrix}1\\\\0\\\\0\\\\0\\end{matrix}\\right]\\right]\\right), \\  \\left( 3, \\  2, \\  \\left[ \\left[\\begin{matrix}\\frac{1}{3}\\\\0\\\\1\\\\0\\end{matrix}\\right]\\right]\\right)\\right]$,\\\\\nMacierz nie jest diagonalizowalna.')
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}0 & 0 & 1 & -1\\0 & -1 & 0 & 1\\0 & 0 & 3 & -1\\0 & 0 & 0 & 3\end{matrix}\right]
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} - 5 \lambda^{3} + 3 \lambda^{2} + 9 \lambda$, \quad 
Wartości własne:$ \left\{ -1 : 1, \  0 : 1, \  3 : 2\right\}, $\\
\parbox{4em}{Wektory\\własne:} $\left[ \left( -1, \  1, \  \left[ \left[\begin{matrix}0\\1\\0\\0\end{matrix}\right]\right]\right), \  \left( 0, \  1, \  \left[ \left[\begin{matrix}1\\0\\0\\0\end{matrix}\right]\right]\right), \  \left( 3, \  2, \  \left[ \left[\begin{matrix}\frac{1}{3}\\0\\1\\0\end{matrix}\right]\right]\right)\right]$,\\
Macierz nie jest diagonalizowalna.
***********************************************************************************************
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}2 & 0 & 0 & 2\\3 & 1 & -1 & -2\\-2 & 0 & -1 & 2\\2 & 0 & 0 & 2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} - 4 \lambda^{3} - \lambda^{2} + 4 \lambda\]

Wartości własne

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

Wektory własne

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

Diagonalizacja:

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

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

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

Wartości własne

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

Wektory własne

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

Diagonalizacja:

Macierz nie jest diagonalizowalna

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

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

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

Wartości własne

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

Wektory własne

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

Diagonalizacja:

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

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

\[\begin{split} \textnormal{A=} \left[\begin{matrix}3 & -2\\2 & -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\\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 & 2 & -2 & 0\\-1 & 0 & 1 & -2\\-1 & 3 & -2 & -2\\1 & 0 & -2 & -2\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} + 5 \lambda^{3} + \lambda^{2} - 21 \lambda - 18\]

Wartości własne

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

Wektory własne

\[\begin{split}\left[ \left( -3, \ 2, \ \left[ \left[\begin{matrix}0\\\frac{1}{2}\\\frac{1}{2}\\1\end{matrix}\right]\right]\right), \ \left( -1, \ 1, \ \left[ \left[\begin{matrix}2\\1\\1\\0\end{matrix}\right]\right]\right), \ \left( 2, \ 1, \ \left[ \left[\begin{matrix}0\\-2\\-2\\1\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}-1 & 3 & 0 & 2\\-2 & -2 & 2 & 2\\-2 & 3 & 1 & 2\\-1 & 1 & 1 & -1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} + 3 \lambda^{3} - \lambda^{2} - 3 \lambda\]

Wartości własne

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

Wektory własne

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

Diagonalizacja:

\[\begin{split}A = P\,D\,P^{-1}: \quad P=\left[\begin{matrix}2 & 1 & 5 & 14\\-2 & 0 & 1 & 6\\2 & 1 & 5 & 18\\1 & 0 & 1 & 5\end{matrix}\right],\quad D=\left[\begin{matrix}-3 & 0 & 0 & 0\\0 & -1 & 0 & 0\\0 & 0 & 0 & 0\\0 & 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 & 2\\0 & 2 & 0\\2 & 3 & -1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{3} - 3 \lambda^{2} - 4 \lambda + 12\]

Wartości własne

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

Wektory własne

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

Diagonalizacja:

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

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

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

Wartości własne

\[ \left\{ 0 : 1, \ 1 : 1, \ 3 : 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}-1\\0\\1\end{matrix}\right]\right]\right), \ \left( 3, \ 1, \ \left[ \left[\begin{matrix}-3\\-1\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

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

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

\[\begin{split} \textnormal{A=} \left[\begin{matrix}3 & 0 & 0\\-2 & -1 & 2\\2 & 0 & 2\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\\1\\0\end{matrix}\right]\right]\right), \ \left( 2, \ 1, \ \left[ \left[\begin{matrix}0\\\frac{2}{3}\\1\end{matrix}\right]\right]\right), \ \left( 3, \ 1, \ \left[ \left[\begin{matrix}\frac{1}{2}\\\frac{1}{4}\\1\end{matrix}\right]\right]\right)\right]\end{split}\]

Diagonalizacja:

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

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

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-1 & -2 & -1 & 0\\1 & 2 & -1 & 0\\0 & 0 & -2 & 0\\-2 & 1 & -1 & 0\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}\frac{2}{3}\\0\\\frac{2}{3}\\1\end{matrix}\right]\right]\right), \ \left( 0, \ 2, \ \left[ \left[\begin{matrix}0\\0\\0\\1\end{matrix}\right]\right]\right), \ \left( 1, \ 1, \ \left[ \left[\begin{matrix}- \frac{1}{3}\\\frac{1}{3}\\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\\\\0 & 1\\end{matrix}\\right]\n\t\\]',
 '$\\det\\left(\\lambda \\mathbb{I} - A \\right) = \\lambda^{2} - 2 \\lambda + 1$, \\quad \nWartości własne:$ \\left\\{ 1 : 2\\right\\}, $\\\\\n\\parbox{4em}{Wektory\\\\własne:} $\\left[ \\left( 1, \\  2, \\  \\left[ \\left[\\begin{matrix}1\\\\0\\end{matrix}\\right], \\  \\left[\\begin{matrix}0\\\\1\\end{matrix}\\right]\\right]\\right)\\right]$,\\\\\n$A = P\\,D\\,P^{-1}: \\quad P=\\left[\\begin{matrix}1 & 0\\\\0 & 1\\end{matrix}\\right],$ \\quad \n$D=\\left[\\begin{matrix}1 & 0\\\\0 & 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\\0 & 1\end{matrix}\right]
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
$\det\left(\lambda \mathbb{I} - A \right) = \lambda^{2} - 2 \lambda + 1$, \quad 
Wartości własne:$ \left\{ 1 : 2\right\}, $\\
\parbox{4em}{Wektory\\własne:} $\left[ \left( 1, \  2, \  \left[ \left[\begin{matrix}1\\0\end{matrix}\right], \  \left[\begin{matrix}0\\1\end{matrix}\right]\right]\right)\right]$,\\
$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]$
***********************************************************************************************
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\\0 & 1 & 0 & 0\\-2 & -2 & -2 & -1\\0 & 1 & 1 & -1\end{matrix}\right] \end{split}\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\det\left(\lambda \mathbb{I} - A \right) = \lambda^{4} + \lambda^{3} - 2 \lambda^{2} - 3 \lambda + 3\]

Wartości własne

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

Wektory własne

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

Diagonalizacja:

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

Przeprowadzić diagonalizację macierzy

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

Wartości własne

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

Wektory własne

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

Diagonalizacja:

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

Przeprowadzić diagonalizację macierzy

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

Wartości własne

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

Wektory własne

\[\begin{split}\left[ \left( -1, \ 1, \ \left[ \left[\begin{matrix}1\\-1\\1\end{matrix}\right]\right]\right), \ \left( 0, \ 2, \ \left[ \left[\begin{matrix}0\\1\\0\end{matrix}\right], \ \left[\begin{matrix}2\\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 & 2\\-1 & 1 & 0\\1 & 0 & 1\end{matrix}\right],\quad D=\left[\begin{matrix}-1 & 0 & 0\\0 & 0 & 0\\0 & 0 & 0\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 4 **********************************************************************************

Przeprowadzić diagonalizację macierzy

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

Wartości własne

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

Wektory własne

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

Diagonalizacja:

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

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 6 **********************************************************************************

Przeprowadzić diagonalizację macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}-2 & 0\\0 & -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}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}-2 & 0\\0 & -2\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 7 **********************************************************************************

Przeprowadzić diagonalizację macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}2 & 0\\0 & 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}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}2 & 0\\0 & 2\end{matrix}\right]\end{split}\]
***********************************************************************************************
** Zadanie 8 **********************************************************************************

Przeprowadzić diagonalizację macierzy

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

Wartości własne

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

Wektory własne

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

Diagonalizacja:

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

Przeprowadzić diagonalizację macierzy

\[\begin{split} \textnormal{A=} \left[\begin{matrix}2 & 0\\0 & 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}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}2 & 0\\0 & 2\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(3,2),\\  (-3,1),\\  (-4,-3),\\  (0,0),\\  (-5,-2).\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}3 & 1\\\\-3 & 1\\\\-4 & 1\\\\0 & 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}2\\\\1\\\\-3\\\\0\\\\-2\\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} \\frac{1}{2} \\\\ \\frac{1}{2} \\end{matrix}\\right]\n\t\\]\n\t&\n\t\t\\raisebox{-4.9cm}{\\resizebox{5.2cm}{!}{\\includegraphics{../pics/regresja1}}}\n\t\\end{tabular}\n')
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 
	\[
		(3,2),\  (-3,1),\  (-4,-3),\  (0,0),\  (-5,-2).
	\]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
	\begin{tabular}{p{0.5\textwidth}p{0.3\textwidth}}
	\vspace{0pt}
	\[
		\left[\begin{matrix}3 & 1\\-3 & 1\\-4 & 1\\0 & 1\\-5 & 1\end{matrix}\right]
		\cdot \left[\begin{matrix} a \\ b \end{matrix}\right]
		\simeq \left[\begin{matrix}2\\1\\-3\\0\\-2\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} \frac{1}{2} \\ \frac{1}{2} \end{matrix}\right]
	\]
	&
		\raisebox{-4.9cm}{\resizebox{5.2cm}{!}{\includegraphics{../pics/regresja1}}}
	\end{tabular}

***********************************************************************************************
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ć trójmian kwadratowy regresji dla punktów

\[ (3,-2),\ (-2,3),\ (-4,5),\ (2,-1),\ (0,1). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}9 & 3 & 1\\4 & -2 & 1\\16 & -4 & 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\\3\\5\\-1\\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 2 **********************************************************************************

Wyznaczyć prostą regresji dla punktów

\[ (-1,-1),\ (-5,3),\ (1,-2),\ (3,0),\ (-2,2). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}-1 & 1\\-5 & 1\\1 & 1\\3 & 1\\-2 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \end{matrix}\right] \simeq \left[\begin{matrix}-1\\3\\-2\\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} \\ 0 \end{matrix}\right]\end{split}\]

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

Wyznaczyć trójmian kwadratowy regresji dla punktów

\[ (-3,-3),\ (0,-4),\ (3,-1),\ (1,-2),\ (-2,-5). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}9 & -3 & 1\\0 & 0 & 1\\9 & 3 & 1\\1 & 1 & 1\\4 & -2 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \\ c \end{matrix}\right] \simeq \left[\begin{matrix}-3\\-4\\-1\\-2\\-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{1}{6} \\ \frac{1}{2} \\ - \frac{11}{3} \end{matrix}\right]\end{split}\]

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

Wyznaczyć trójmian kwadratowy regresji dla punktów

\[ (-1,0),\ (1,4),\ (-3,-4),\ (0,2),\ (-2,-2). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}1 & -1 & 1\\1 & 1 & 1\\9 & -3 & 1\\0 & 0 & 1\\4 & -2 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \\ c \end{matrix}\right] \simeq \left[\begin{matrix}0\\4\\-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 \\ c \end{matrix}\right] = \left[\begin{matrix} 0 \\ 2 \\ 2 \end{matrix}\right]\end{split}\]

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

Wyznaczyć prostą regresji dla punktów

\[ (-1,1),\ (1,-1),\ (-5,5),\ (4,-4),\ (2,-2). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}-1 & 1\\1 & 1\\-5 & 1\\4 & 1\\2 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \end{matrix}\right] \simeq \left[\begin{matrix}1\\-1\\5\\-4\\-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 \\ 0 \end{matrix}\right]\end{split}\]

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

Wyznaczyć prostą regresji dla punktów

\[ (-3,0),\ (5,-2),\ (4,-4),\ (3,-5),\ (-4,1). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}-3 & 1\\5 & 1\\4 & 1\\3 & 1\\-4 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \end{matrix}\right] \simeq \left[\begin{matrix}0\\-2\\-4\\-5\\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} - \frac{1}{2} \\ - \frac{3}{2} \end{matrix}\right]\end{split}\]

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

Wyznaczyć prostą regresji dla punktów

\[ (5,-5),\ (-5,4),\ (-2,1),\ (2,-2),\ (-4,2). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}5 & 1\\-5 & 1\\-2 & 1\\2 & 1\\-4 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \end{matrix}\right] \simeq \left[\begin{matrix}-5\\4\\1\\-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} - \frac{5}{6} \\ - \frac{2}{3} \end{matrix}\right]\end{split}\]

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

Wyznaczyć trójmian kwadratowy regresji dla punktów

\[ (2,-5),\ (-1,0),\ (0,-2),\ (3,-1),\ (-4,3). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}4 & 2 & 1\\1 & -1 & 1\\0 & 0 & 1\\9 & 3 & 1\\16 & -4 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \\ c \end{matrix}\right] \simeq \left[\begin{matrix}-5\\0\\-2\\-1\\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{1}{6} \\ - \frac{2}{3} \\ -2 \end{matrix}\right]\end{split}\]

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

Wyznaczyć trójmian kwadratowy regresji dla punktów

\[ (-1,1),\ (-4,-2),\ (2,0),\ (3,-4),\ (0,5). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}1 & -1 & 1\\16 & -4 & 1\\4 & 2 & 1\\9 & 3 & 1\\0 & 0 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \\ c \end{matrix}\right] \simeq \left[\begin{matrix}1\\-2\\0\\-4\\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{1}{2} \\ - \frac{2}{3} \\ 3 \end{matrix}\right]\end{split}\]

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

Wyznaczyć trójmian kwadratowy regresji dla punktów

\[ (-2,-5),\ (-1,-4),\ (1,-3),\ (-5,5),\ (2,2). \]
***********************************************************************************************
** Rozwiązanie ********************************************************************************
\[\begin{split}\left[\begin{matrix}4 & -2 & 1\\1 & -1 & 1\\1 & 1 & 1\\25 & -5 & 1\\4 & 2 & 1\end{matrix}\right] \cdot \left[\begin{matrix} a \\ b \\ c \end{matrix}\right] \simeq \left[\begin{matrix}-5\\-4\\-3\\5\\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 \\ c \end{matrix}\right] = \left[\begin{matrix} \frac{2}{3} \\ \frac{3}{2} \\ - \frac{25}{6} \end{matrix}\right]\end{split}\]

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