## 2017年11月25日土曜日

### 数学 - Python - もう１つの数学の基盤 - 行列と行列式 – 行列とその演算 - 行列の乗法の性質(2)(正方行列(2次)、等式、単位行列、累乗(べき乗))

1. $\begin{array}{}\left(\begin{array}{cc}{a}^{2}+bc& ab+bd\\ ac+cd& bc+{d}^{2}\end{array}\right)\end{array}-\left(\begin{array}{cc}{a}^{2}+ad& ab+bd\\ ac+cd& ad+{d}^{2}\end{array}\right)+\left(\begin{array}{cc}ad-bc& 0\\ 0& ad-bc\end{array}\right)=\left(\begin{array}{cc}0& 0\\ 0& 0\end{array}\right)$

2. $\begin{array}{}d=-a\\ -{a}^{2}-bc=1\\ {a}^{2}+bc=-1\end{array}$
$\begin{array}{}\left(\begin{array}{cc}{a}^{2}+bc& ab+bd\\ ac+cd& bc+{d}^{2}\end{array}\right)\end{array}=\left(\begin{array}{cc}-1& b\left(a+d\right)\\ c\left(a+d\right)& bc+{a}^{2}\end{array}\right)\\ =\left(\begin{array}{cc}-1& 0\\ 0& -1\end{array}\right)\\ =-\left(\begin{array}{cc}1& 0\\ 0& 1\end{array}\right)\\ =-E$

3. $\begin{array}{}d=1-a\\ a\left(1-a\right)-bc=0\\ a-{a}^{2}-bc=0\end{array}$
$\begin{array}{}\left(\begin{array}{cc}{a}^{2}+bc& ab+bd\\ ac+cd& bc+{d}^{2}\end{array}\right)\end{array}=\left(\begin{array}{cc}{a}^{2}+\left(a-{a}^{2}\right)& b\left(a+d\right)\\ c\left(a+d\right)& bc+{\left(1-a\right)}^{2}\end{array}\right)\\ =\left(\begin{array}{cc}a& b\\ c& \left(a-{a}^{2}\right)+{\left(1-a\right)}^{2}\end{array}\right)\\ =\left(\begin{array}{cc}a& b\\ c& -a+1\end{array}\right)\\ =\left(\begin{array}{cc}a& b\\ c& d\end{array}\right)\\ =A$

コード(Emacs)

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, Matrix, solve

a, b, c, d = symbols('a, b, c, d')
A = Matrix([[a, b],
[c, d]])

E = Matrix([[1, 0],
[0, 1]])
X = A ** 2 - (a + d) * A + (a * d - b * c) * E
for t in [X, X.expand()]:
pprint(t)
print()


$./sample16.py ⎡ 2 ⎤ ⎢a + a⋅d - a⋅(a + d) a⋅b + b⋅d - b⋅(a + d)⎥ ⎢ ⎥ ⎢ 2 ⎥ ⎣a⋅c + c⋅d - c⋅(a + d) a⋅d + d - d⋅(a + d) ⎦ ⎡0 0⎤ ⎢ ⎥ ⎣0 0⎦$