summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortanyaionova <isaqtm@gmail.com>2019-11-16 21:35:30 +0300
committertanyaionova <isaqtm@gmail.com>2019-11-16 21:35:30 +0300
commit7360c0ae23653ff0fddec16f91f5eaed88529dfb (patch)
treed7b497075673a37c73a49caef381efc763d31b2c
downloadalg2-7360c0ae23653ff0fddec16f91f5eaed88529dfb.tar.gz
First bunch
-rw-r--r--.gitignore1
-rw-r--r--intro.tex68
-rw-r--r--libsolve.py298
-rw-r--r--phw2.tex379
4 files changed, 746 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c18dd8d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+__pycache__/
diff --git a/intro.tex b/intro.tex
new file mode 100644
index 0000000..f718571
--- /dev/null
+++ b/intro.tex
@@ -0,0 +1,68 @@
+\usepackage[sfdefault,condensed,scaled=0.85]{roboto}
+\usepackage{inconsolata}
+\setmonofont[Scale=0.85]{Inconsolata}
+
+\setlength\headheight{13.6pt}
+
+\usepackage{
+ amsmath, amsthm, amssymb, mathtools,
+ graphicx, subfig, float,
+ listings, xcolor,
+ fancyhdr, sectsty, hyperref, enumerate, framed,
+ comment
+}
+\usepackage[shortlabels]{enumitem}
+
+\flushbottom % Uncomment to make text fill the entire page
+\usepackage[bottom]{footmisc} % Anchor footnotes to bottom of page
+\renewcommand{\baselinestretch}{1.06} % Adjust line spacing
+%\setlength\parindent{0pt} % Remove paragraph indentation
+\usepackage{geometry}\geometry{letterpaper, % Set page margins
+ left=0.7in, right=0.7in,
+ top=0.8in, bottom=0.9in,
+ headsep=.1in
+}
+
+
+\setlength\FrameSep{0.75em}
+\setlength\OuterFrameSep{\partopsep}
+
+\newenvironment{cframed}[1][gray]
+ {\def\FrameCommand{\fboxsep=\FrameSep\fcolorbox{#1}{white}}%
+ \MakeFramed {\advance\hsize-\width \FrameRestore}}
+ {\endMakeFramed}
+
+\newcommand{\question}[2]{
+ \doubleskip\begin{cframed}
+ \noindent \textbf{#1}
+ #2
+ \end{cframed}
+}
+
+\newcommand{\braced}[1]{\left( #1 \right)}
+
+\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
+\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
+
+\DeclareMathOperator{\tg}{tg}
+\DeclareMathOperator{\ctg}{ctg}
+
+\newcommand{\sinx}{\sin x}
+\newcommand{\cosx}{\cos x}
+\newcommand{\tgx}{\tg x}
+
+\newcommand{\doubleskip}{\bigskip \bigskip}
+\newcommand{\osmall}[1]{\overline{o}\left( #1 \right)}
+
+\DeclareRobustCommand{\rchi}{{\mathpalette\irchi\relax}}
+\newcommand{\irchi}[2]{\raisebox{\depth}{$#1\chi$}} % inner command, used by \rchi
+
+\hypersetup{colorlinks=true, linkcolor=magenta}
+
+% -- Left/right header text and footer (to appear on every page) --
+\pagestyle{fancy}
+\renewcommand{\footrulewidth}{0.4pt}
+\renewcommand{\headrulewidth}{0.4pt}
+
+\cfoot{}
+\rfoot{\thepage} \ No newline at end of file
diff --git a/libsolve.py b/libsolve.py
new file mode 100644
index 0000000..d932dd6
--- /dev/null
+++ b/libsolve.py
@@ -0,0 +1,298 @@
+from __future__ import annotations
+from typing import Iterable, Union
+from fractions import Fraction
+from itertools import zip_longest
+
+
+def is_scalar(obj):
+ return isinstance(obj, (Fraction, int))
+
+POLY_COLOR = None
+# POLY_COLOR = '36' # Uncomment to have color
+
+
+# may not work. see
+# https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts
+# to test with your font
+superscripts = '⁰¹²³⁴⁵⁶⁷⁸⁹' # must be <sup>0123456789</sup>
+
+
+def int2sup(n):
+ res = []
+ while n > 0:
+ res.append(superscripts[n % 10])
+ n //= 10
+ return ''.join(reversed(res))
+
+
+class Poly:
+ def __init__(self, vec: Iterable, letter='x'):
+ '''
+ vec: big-endian coefficients
+ '''
+ self.vec = list(vec)
+ self.letter = letter
+ self._trim_zeros()
+
+ def _trim_zeros(self):
+ '''
+ Trim trailing zeros in coefficients: [0, 1, 1, 0] -> [0, 1, 1]
+ Needed for multiplication to work correctly
+ '''
+ len_zeros = 0
+ for c in reversed(self.vec):
+ if c != 0:
+ break
+ len_zeros += 1
+ if len_zeros > 0:
+ self.vec = self.vec[:-len_zeros]
+
+ def __mul__(self, rhs: Union[Poly, Fraction, int]):
+ if is_scalar(rhs):
+ return Poly([c * rhs for c in self.vec])
+
+ elif isinstance(rhs, Poly):
+ # no fft 4 u
+ result = [0] * (self.deg() + rhs.deg() + 1)
+ self._trim_zeros()
+ rhs._trim_zeros()
+ for i in range(len(self.vec)):
+ for j in range(len(rhs.vec)):
+ if all(c != 0 for c in (self.vec[i], rhs.vec[j])):
+ result[i + j] += self.vec[i] * rhs.vec[j]
+ return Poly(result)
+
+ else:
+ raise TypeError(f'{type(rhs)} not supported')
+
+ def __truediv__(self, rhs: Union[Fraction, int]):
+ if is_scalar(rhs):
+ return Poly([c * Fraction(1, rhs) for c in self.vec])
+ else:
+ raise TypeError(f'{type(rhs)} not supported')
+
+ def __add__(self, rhs: Union[Poly, Fraction, int]):
+ if is_scalar(rhs):
+ return Poly([self.vec[0] + rhs] + self.vec[1:])
+ elif isinstance(rhs, Poly):
+ result = []
+ for pair in zip_longest(self.vec, rhs.vec):
+ result.append(sum(c for c in pair if c is not None))
+ return Poly(result)
+
+ def __sub__(self, rhs: Union[Poly, Fraction, int]):
+ return self + (-rhs)
+
+ def __neg__(self):
+ return Poly(-c for c in self.vec)
+
+ def deg(self):
+ '''
+ Get degree of poly
+ '''
+ d = len(self.vec) - 1
+ for c in reversed(self.vec):
+ if c != 0:
+ return d
+ else:
+ d -= 1
+ return max(d, 0)
+
+ def shift(self, deg):
+ '''
+ divide by x^deg, drop rest
+ '''
+ for i in range(deg):
+ del self.vec[0]
+
+ def __repr__(self):
+ return self.get_hint()
+
+ def get_hint(self):
+ '''
+ Get raw text hints for outer structures to align items
+ '''
+ rev = list(reversed(self.vec))
+ if all(r == 0 for r in rev):
+ return '0'
+ d = self.deg()
+ res = []
+ for i in range(len(rev)):
+ if rev[i] == 0:
+ continue
+ if i == 0:
+ if rev[i] < 0:
+ res.append('-')
+ else:
+ if rev[i] < 0:
+ res.append(' - ')
+ else:
+ res.append(' + ')
+
+ if abs(rev[i]) != 1 or i == d:
+ res.append(str(abs(rev[i])))
+ if i != d:
+ res.append(self.letter)
+ if d - i != 1:
+ res.append(int2sup(d - i))
+ return ''.join(res)
+
+
+class Row:
+ '''
+ Matrix row.
+ '''
+
+ def __init__(self, it: Iterable):
+ def make_poly(obj):
+ if isinstance(obj, (int, Fraction)):
+ return Poly([obj])
+ elif isinstance(obj, Poly):
+ return obj
+ else:
+ raise TypeError(f'{type(obj)} not supported')
+
+ self.lst = list(map(make_poly, it))
+ self.hints = 1 * len(self.lst)
+
+ def __add__(self, obj: Row):
+ '''
+ Add another row
+ '''
+ assert isinstance(obj, Row)
+ assert len(obj.lst) == len(self.lst)
+ pairs = zip(self.lst, obj.lst)
+ return Row(map(lambda x: x[0] + x[1], pairs))
+
+ def __mul__(self, k: Union[int, Fraction]):
+ '''
+ Multiply by int or fractions.Fraction
+ '''
+ assert isinstance(k, (int, Fraction))
+ return Row(map(lambda x: x * k, self.lst))
+
+ def __iter__(self):
+ return iter(self.lst)
+
+ def __getitem__(self, key):
+ return self.lst[key]
+
+ def __setitem__(self, key, val):
+ self.lst[key] = val
+
+ def __len__(self):
+ return len(self.lst)
+
+ def __repr__(self):
+ parts = []
+ for el, hint in zip(self.lst, self.hints):
+ part = '{el: >{hint}}'.format(el=repr(el), hint=hint)
+ if el.deg() > 0 and POLY_COLOR is not None:
+ part = '\x1b[' + POLY_COLOR + 'm' + part + '\x1b[0m'
+ parts.append(part)
+
+ return ('[' + ' '.join(parts) + ']')
+
+ def get_hints(self):
+ '''
+ Get hints for other structures to align items
+ '''
+ return [len(el.get_hint()) for el in self.lst]
+
+ def set_hints(self, hints):
+ '''
+ Set hints to align items within row
+ '''
+ self.hints = hints
+
+
+class Matrix:
+ '''
+ Matrix. You can apply three elementary transforms to self.
+ '''
+
+ def __init__(self, rows):
+ def make_row(obj):
+ if isinstance(obj, Row):
+ return obj
+ else:
+ return Row(obj)
+
+ self.rows = list(map(make_row, rows))
+ assert all(len(row) == len(self.rows[0]) for row in self.rows)
+
+ def make_S(self, i: int, j: int, lbd: Union[int, Fraction], axis=0):
+ '''
+ if axis == 0, do transform on rows, else on cols
+ M[i] = M[i] + M[j] * lbd
+ '''
+ if axis == 0:
+ self.rows[i] = self.rows[i] + self.rows[j] * lbd
+ else:
+ for row in self.rows:
+ row[i] = row[i] + row[j] * lbd
+
+ def make_U(self, i: int, j: int, axis=0):
+ '''
+ if axis == 0, do transform on rows, else on cols
+ Swap M[i] and M[j]
+ '''
+ if axis == 0:
+ self.rows[i], self.rows[j] = self.rows[j], self.rows[i]
+ else:
+ for row in self.rows:
+ row[i], row[j] = row[j], row[i]
+
+ def make_D(self, i: int, lbd: Union[int, Fraction], axis=0):
+ '''
+ if axis == 0, do transform on rows, else on cols
+ Multiply M[i] by rational lbd
+ '''
+ if axis == 0:
+ self.rows[i] = self.rows[i] * lbd
+ else:
+ for row in self.rows:
+ row[i] = row[i] * lbd
+
+ def det(self) -> Poly:
+ '''
+ Get determinant of matrix
+ '''
+ assert all(len(row) == len(self.rows) for row in self.rows)
+ if len(self.rows) == 1:
+ return self.rows[0][0]
+ res = Poly([0])
+ try:
+ for i in range(len(self.rows[0])):
+ cofactor = Matrix([
+ self.rows[j][:i] + self.rows[j][i + 1:]
+ for j in range(1, len(self.rows))
+ ])
+ res += cofactor.det() * (-1) ** i * self.rows[0][i]
+ except Exception as e:
+ print(self)
+ raise e
+
+ return res
+
+ def __sub__(self, oth):
+ return self + (-oth)
+
+ def __neg__(self):
+ rows = [row * (-1) for row in self.rows]
+ return Matrix(rows)
+
+ def __add__(self, oth):
+ rows = [row1 + row2 for row1, row2 in zip(self.rows, oth.rows)]
+ return Matrix(rows)
+
+ def __repr__(self):
+ hints = [row.get_hints() for row in self.rows]
+ max_hints = []
+ for i in range(len(hints)):
+ max_hints.append(max(hints[j][i] for j in range(len(hints))))
+
+ for row in self.rows:
+ row.set_hints(max_hints)
+
+ return '\n'.join(repr(row) for row in self.rows)
diff --git a/phw2.tex b/phw2.tex
new file mode 100644
index 0000000..1138761
--- /dev/null
+++ b/phw2.tex
@@ -0,0 +1,379 @@
+\documentclass[11pt]{article}
+%\usepackage[T2A]{fontenc}
+%\usepackage[utf8]{inputenc}
+%\usepackage[russian]{babel}
+
+
+\input{intro}
+
+\lhead{\color{gray} Линейная алгебра}
+\rhead{\color{gray} ИДЗ-2}
+
+\makeatletter
+\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
+ \hskip -\arraycolsep
+ \let\@ifnextchar\new@ifnextchar
+ \array{#1}}
+\makeatother
+
+
+\DeclareMathOperator{\chr}{char}
+
+\title{ИДЗ-2 по линейной алгебре}
+\author{Шарафатдинов Камиль БПМИ-192}
+\date{\today}
+
+% -- Here bet dragons --
+\begin{document}
+\maketitle
+%\section*{Abstract}
+
+\clearpage
+
+\question{2}{
+\[
+ \begin{pmatrix}
+ -1 & 1 & 2 & 3\\
+ 3 & -3 & -2 & -3\\
+ -2 & -3 & 2 & 2\\
+ 1 & -1 & -3 & -3
+ \end{pmatrix}
+ \braced{
+ X +
+ \begin{pmatrix}
+ -10 & 8 & -5 & 1\\
+ 8 & -1 & -1 & 6\\
+ 4 & -5 & 4 & -5\\
+ 10 & -9 & 8 & 3
+ \end{pmatrix}
+ }^{-1}
+ \begin{pmatrix}
+ 2 & -3 & -1 & -2\\
+ -3 & 2 & -2 & 3\\
+ -1 & 2 & 3 & 3\\
+ 3 & -3 & -2 & -3
+ \end{pmatrix}
+ =
+ \begin{pmatrix}
+ 1 & 1 & -1 & 1\\
+ -1 & -2 & 2 & -2\\
+ 1 & 2 & -1 & 3\\
+ -1 & -2 & 1 & -2
+ \end{pmatrix}
+\]
+}
+
+ Обозначим как-нибудь матрицы:
+ \[
+ A (X + B)^{-1} C = D
+ \]
+
+ Предположим, что $A$ и $D$ обратимы ($D^{-1}$ мне все равно придется найти, а $\Delta A = -30$). Тогда
+ \begin{align*}
+ A (X + B)^{-1} C &= D\\
+ (X + B)^{-1} C &= A^{-1} D\\
+ C &= (X + B) A^{-1} D\\
+ C D^{-1} &= (X + B) A^{-1}\\
+ C D^{-1} A &= X + B\\
+ X &= C D^{-1} A - B
+ \end{align*}
+
+ Найдем $D^{-1}$. Запишем матрицу $(D|E)$ и будем элементарными преобразованиями приводить ее к $(E|D^{-1})$.
+ \[
+ \begin{pmatrix}[cccc|cccc]
+ 1 & 1 & -1 & 1 & 1 & 0 & 0 & 0\\
+ -1 & -2 & 2 & -2 & 0 & 1 & 0 & 0\\
+ 1 & 2 & -1 & 3 & 0 & 0 & 1 & 0\\
+ -1 & -2 & 1 & -2 & 0 & 0 & 0 & 1
+ \end{pmatrix} \overset{\texttt{main2.py}}\sim % TODO
+ \begin{pmatrix}[cccc|cccc]
+ 1 & 0 & 0 & 0 & 2 & 1 & 0 & 0\\
+ 0 & 1 & 0 & 0 & -1 & 0 & -1 & -2\\
+ 0 & 0 & 1 & 0 & 0 & 1 & 0 & -1\\
+ 0 & 0 & 0 & 1 & 0 & 0 & 1 & 1
+ \end{pmatrix}
+ \]
+
+ Осталось просто перемножить $CD^{-1}A$ и вычесть $B$
+ \[
+ X = CD^{-1}A - B =
+ \begin{pmatrix}
+ -1 & -4 & -1 & 5\\
+ -8 & 3 & -7 & -10\\
+ 4 & -9 & 2 & -4\\
+ -1 & 1 & 1 & 9
+ \end{pmatrix} - B =
+ \begin{pmatrix}
+ 9 & -12 & 4 & 4\\
+ -16 & 4 & -6 & -16\\
+ 0 & -4 & -2 & 1\\
+ -11 & 10 & -7 & 6
+ \end{pmatrix}
+ \]
+
+\question{3}{
+ \[
+ A =
+ \begin{pmatrix}
+ -4 & 3 & -2 & 1\\
+ -5 & 5 & -4 & 1\\
+ 2 & -2 & 1 & -2\\
+ 0 & 0 & 2 & 2
+ \end{pmatrix}
+ \]
+ Найти характеристический многочлен $A$ и определитель $(A^2 - 3A + 1)^{-2}$
+}
+
+ \[
+ \det\braced{A - \lambda E} =
+ \begin{vmatrix}
+ -4 -\lambda & 3 & -2 & 1\\
+ -5 & 5 -\lambda & -4 & 1\\
+ 2 & -2 & 1 -\lambda & -2\\
+ 0 & 0 & 2 & 2 -\lambda
+ \end{vmatrix}
+ \]
+
+ Разложим по последней строке
+ \begin{align*}
+ &\begin{vmatrix}
+ -4 -\lambda & 3 & -2 & 1\\
+ -5 & 5 -\lambda & -4 & 1\\
+ 2 & -2 & 1 -\lambda & -2\\
+ 0 & 0 & 2 & 2 -\lambda
+ \end{vmatrix} =
+ -2 \begin{vmatrix}
+ -4 -\lambda & 3 & 1\\
+ -5 & 5 -\lambda & 1\\
+ 2 & -2 & -2\\
+ \end{vmatrix} + (2 - \lambda)
+ \begin{vmatrix}
+ -4 -\lambda & 3 & -2\\
+ -5 & 5 -\lambda & -4\\
+ 2 & -2 & 1 -\lambda\\
+ \end{vmatrix} =\\\\
+ = &(-2)(-2\lambda^2 + 2\lambda + 8) + (2 - \lambda)(-\lambda^3 + 2\lambda^2 + 8\lambda + 3) =
+ \lambda^4 - 4\lambda^3 + 9\lambda - 10
+ \end{align*}
+
+ Посмотрим внимательно на $(A^2 - 3A + 2)^{-2}$. Пусть $B = A^2 - 3A + 2 = (A - 1)(A - 2)$.
+ \[
+ \det(B^{-2}) =
+ \det(B^{-1})^2 =
+ \braced{ \frac{1}{\det(B)} }^2 =
+ \braced{ \frac{1}{\det(A - 1)\det(A - 2)} }^2
+ \]
+
+ Осталось посчитать $\det(A - 1)$ и $\det(A - 2)$
+ \[
+ \det(A - 1) =
+ \begin{vmatrix}
+ -5 & 3 & -2 & 1\\
+ -5 & 4 & -4 & 1\\
+ 2 & -2 & 0 & -2\\
+ 0 & 0 & 2 & 1
+ \end{vmatrix} =
+ -2
+ \begin{vmatrix}
+ -5 & 3 & 1\\
+ -5 & 4 & 1\\
+ 2 & -2 & -2
+ \end{vmatrix} +
+ \begin{vmatrix}
+ -5 & 3 & -2\\
+ -5 & 4 & -4\\
+ 2 & -2 & 0
+ \end{vmatrix} = -4
+ \]
+
+ \[
+ \det(A - 2) =
+ \begin{vmatrix}
+ -6 & 3 & -2 & 1\\
+ -5 & 3 & -4 & 1\\
+ 2 & -2 & -1 & -2\\
+ 0 & 0 & 2 & 0
+ \end{vmatrix} =
+ -2
+ \begin{vmatrix}
+ -6 & 3 & 1\\
+ -5 & 3 & 1\\
+ 2 & -2 & -2
+ \end{vmatrix} = -8
+ \]
+
+ \[
+ \det\braced{A^2 - 3A + 2}^{-2} = \braced{ \frac{1}{32} }^2 = \frac{1}{1024}
+ \]
+
+
+\question{4}{
+ Найти коэффициент при $x^5$ в
+ \[
+ \begin{vmatrix}
+ x & 4 & -5 & 5 & -7 & 8 & 1\\
+ 1 & 5 & 8 & -8 & -5 & x & 5\\
+ -4 & 7 & x & -6 & -1 & -2 & 1\\
+ -8 & 4 & 7 & 7 & 6 & x & 8\\
+ -9 & -6 & 8 & -5 & -5 & 8 & x\\
+ -2 & 7 & 1 & 4 & x & 3 & 4\\
+ 2 & x & 6 & x & 9 & -2 & 3\\
+ \end{vmatrix}
+ \]
+}
+
+ Сделаем пару преобразований, чтобы сократить количество иксов:
+ \begin{align*}
+ &\begin{vmatrix}
+ x & 4 & -5 & 5 & -7 & 8 & 1\\
+ 1 & 5 & 8 & -8 & -5 & x & 5\\
+ -4 & 7 & x & -6 & -1 & -2 & 1\\
+ -8 & 4 & 7 & 7 & 6 & x & 8\\
+ -9 & -6 & 8 & -5 & -5 & 8 & x\\
+ -2 & 7 & 1 & 4 & x & 3 & 4\\
+ 2 & x & 6 & x & 9 & -2 & 3\\
+ \end{vmatrix} \overset{\text{2 строка -= 4 строка}}=
+ \begin{vmatrix}
+ x & 4 & -5 & 5 & -7 & 8 & 1\\
+ 9 & 1 & 1 & -15 & -11 & 0 & -3\\
+ -4 & 7 & x & -6 & -1 & -2 & 1\\
+ -8 & 4 & 7 & 7 & 6 & x & 8\\
+ -9 & -6 & 8 & -5 & -5 & 8 & x\\
+ -2 & 7 & 1 & 4 & x & 3 & 4\\
+ 2 & x & 6 & x & 9 & -2 & 3\\
+ \end{vmatrix} =\\\\
+ \overset{\text{2 столбец -= 4 столбец}}= &\begin{vmatrix}
+ x & -1 & -5 & 5 & -7 & 8 & 1\\
+ 9 & 16 & 1 & -15 &-11 & 0 & -3\\
+ -4 & 13 & x & -6 & -1 & -2 & 1\\
+ -8 & -3 & 7 & 7 & 6 & x & 8\\
+ -9 & -1 & 8 & -5 & -5 & 8 & x\\
+ -2 & 3 & 1 & 4 & x & 3 & 4\\
+ 2 & 0 & 6 & x & 9 & -2 & 3\\
+ \end{vmatrix}
+ \end{align*}
+
+ Заметим, что иксов осталось 6 - по одному в каждом стобце и строке кроме одного.
+ $x^5$ возникает в сумме членов определителя, когда вместо одного из иксов мы берем другое число из строки.
+ Соотвестственно, надо выписать все перестановки, в которых остается 5 иксов, или, что равносильно, в которых
+ отсутствует ровно один икс. таких перестановок 6, так как без каждого икса есть ровно две перестановки, но одна
+ из них содержит шестой икс, поэтому нам подходит только вторая.
+
+ Итак, перестановки, содержащие 5 иксов:
+ \begin{align*}
+ &\begin{pmatrix}
+ 1 & 2 & 3 & 4 & 5 & 6 & 7\\
+ 2 & 1 & 3 & 6 & 7 & 5 & 4
+ \end{pmatrix} \quad \text{знак} = 1\\
+ &\begin{pmatrix}
+ 1 & 2 & 3 & 4 & 5 & 6 & 7\\
+ 1 & 3 & 2 & 6 & 7 & 5 & 4
+ \end{pmatrix} \quad \text{знак} = 1\\
+ &\begin{pmatrix}
+ 1 & 2 & 3 & 4 & 5 & 6 & 7\\
+ 1 & 6 & 3 & 2 & 7 & 5 & 4
+ \end{pmatrix} \quad \text{знак} = 1\\
+ &\begin{pmatrix}
+ 1 & 2 & 3 & 4 & 5 & 6 & 7\\
+ 1 & 7 & 3 & 6 & 2 & 5 & 4
+ \end{pmatrix} \quad \text{знак} = 1\\
+ &\begin{pmatrix}
+ 1 & 2 & 3 & 4 & 5 & 6 & 7\\
+ 1 & 5 & 3 & 6 & 7 & 2 & 4
+ \end{pmatrix} \quad \text{знак} = 1\\
+ &\begin{pmatrix}
+ 1 & 2 & 3 & 4 & 5 & 6 & 7\\
+ 1 & 4 & 3 & 6 & 7 & 5 & 2
+ \end{pmatrix} \quad \text{знак} = 1\\
+ \end{align*}
+
+ Осталось просто просуммировать произведения константных коэффициентов:
+ \[
+ -9 + 13 + 0 + 3 - 33 + 0 = -26
+ \]
+
+ Это и будет коэффициентом при $x^5$
+
+\question{5}{
+ \[
+ A = \begin{pmatrix}
+ -4 & 4\\
+ 1 & -1\\
+ 3 & -3\\
+ 2 & -2\\
+ 4 & -4
+ \end{pmatrix},
+ B = \begin{pmatrix}
+ 3 & -1 & 1 & -2 & 2\\
+ 1 & 3 & -2 & 2 & -1
+ \end{pmatrix},
+ \qquad \text{Найти: } \rchi_{AB}(\lambda)
+ \]
+}
+
+ Перемножим $AB$ (это несложно, в каждой ячейке всего 2 множителя):
+ \[
+ AB = \begin{pmatrix}
+ -8 & 16 & -12 & 16 & -12\\
+ 2 & -4 & 3 & -4 & 3\\
+ 6 & 12 & 9 & -12 & 9\\
+ 4 & -8 & 6 & -8 & 6\\
+ 8 & -16 & 12 & -16 & 12
+ \end{pmatrix}
+ \]
+
+ Нам нужно посчитать определитель $AB - \lambda E$, поэтому мы можем умножать оба слагаемых на $S_{ij}(k)$ и определитель не изменится
+ \begin{align*}
+ \begin{pmatrix}[ccccc|ccccc]
+ -8 & 16 & -12 & 16 & -12 & \lambda & 0 & 0 & 0 & 0\\
+ 2 & -4 & 3 & -4 & 3 & 0 & \lambda & 0 & 0 & 0\\
+ 6 & 12 & 9 & -12 & 9 & 0 & 0 & \lambda & 0 & 0\\
+ 4 & -8 & 6 & -8 & 6 & 0 & 0 & 0 & \lambda & 0\\
+ 8 & -16 & 12 & -16 & 12 & 0 & 0 & 0 & 0 & \lambda
+ \end{pmatrix}\\\\
+ \text{Прибавим вторую строку к остальным с коэффициентом}\\\\
+ \begin{pmatrix}[ccccc|ccccc]
+ 0 & 0 & 0 & 0 & 0 & \lambda & 4\lambda & 0 & 0 & 0\\
+ 2 & -4 & 3 & -4 & 3 & 0 & \lambda & 0 & 0 & 0\\
+ 0 & 0 & 0 & 0 & 0 & 0 & -3\lambda & \lambda & 0 & 0\\
+ 0 & 0 & 0 & 0 & 0 & 0 & -2\lambda & 0 & \lambda & 0\\
+ 0 & 0 & 0 & 0 & 0 & 0 & -4\lambda & 0 & 0 & \lambda
+ \end{pmatrix}\\
+ \end{align*}
+
+ Теперь можно сложить и просто привести к треугольному виду,
+ пользуясь полилинейностью по строкам и столбцам
+
+ \begin{align*}
+ &\begin{vmatrix}
+ -\lambda & -4\lambda & 0 & 0 & 0\\
+ 2 & -4 -\lambda & 3 & -4 & 3\\
+ 0 & 3\lambda & -\lambda & 0 & 0\\
+ 0 & 2\lambda & 0 & -\lambda & 0\\
+ 0 & 4\lambda & 0 & 0 & -\lambda
+ \end{vmatrix} =
+ \lambda^4 \begin{vmatrix}
+ -1 & -4 & 0 & 0 & 0\\
+ 2 & -4 -\lambda & 3 & -4 & 3\\
+ 0 & 3 & -1 & 0 & 0\\
+ 0 & 2 & 0 & -1 & 0\\
+ 0 & 4 & 0 & 0 & -1
+ \end{vmatrix} =
+ \lambda^4 \begin{vmatrix}
+ -1 & -4 & 0 & 0 & 0\\
+ 2 & 9 -\lambda & 0 & 0 & 0\\
+ 0 & 3 & -1 & 0 & 0\\
+ 0 & 2 & 0 & -1 & 0\\
+ 0 & 4 & 0 & 0 & -1
+ \end{vmatrix} =\\
+ &\lambda^4 \begin{vmatrix}
+ -1 & 0 & 0 & 0 & 0\\
+ 2 & 1 -\lambda & 0 & 0 & 0\\
+ 0 & 3 & -1 & 0 & 0\\
+ 0 & 2 & 0 & -1 & 0\\
+ 0 & 4 & 0 & 0 & -1
+ \end{vmatrix} =
+ \lambda^4 (1 - \lambda) = -\lambda^5 + \lambda^4
+ \end{align*}
+
+\end{document}