## 2017年12月13日水曜日

### 数学 - Python - もう１つの数学の基盤 - 行列と行列式 – 行列式 - 3次の行列式の諸性質(行、列、定数倍、和、記号)

1. $\begin{array}{}|\begin{array}{ccc}0& 1& 0\\ 1-{a}^{2}& a& 1-a\\ 1-a& 1& a-1\end{array}|\end{array}=-\left(\left(1-{a}^{2}\right)\left(a-1\right)-{\left(1-a\right)}^{2}\right)\\ =\left(1-{a}^{2}\right)\left(1-a\right)+{\left(1-a\right)}^{2}\\ ={\left(1-a\right)}^{2}\left(1+a+1\right)\\ ={\left(1-a\right)}^{2}\left(a+2\right)\\ ={\left(a-1\right)}^{2}\left(a+2\right)$

2. $\begin{array}{}|\begin{array}{ccc}1& a& b-a\\ a& 1& 0\\ b& 1& 0\end{array}|\end{array}=\left(b-a\right)\left(a-b\right)\\ =-{\left(a-b\right)}^{2}$

3. $\begin{array}{}a\left(bc-{a}^{2}\right)-b\left({b}^{2}-ac\right)+c\left(ab-{c}^{2}\right)\\ =abc-{a}^{3}-{b}^{3}+abc+abc-{c}^{3}\\ =3abc-{a}^{3}-{b}^{3}-{c}^{3}\end{array}$

4. $\begin{array}{}|\begin{array}{ccc}1& 0& 0\\ a& b-a& c-a\\ {a}^{2}& {b}^{2}-{a}^{2}& {c}^{2}-{a}^{2}\end{array}|\end{array}=\left(b-a\right)\left({c}^{2}-{a}^{2}\right)-\left(c-a\right)\left({b}^{2}-{a}^{2}\right)\\ =\left(c-a\right)\left(b-a\right)\left(\left(c-a\right)-\left(b+a\right)\right)\\ =\left(c-a\right)\left(b-a\right)\left(c-b\right)\\ =\left(a-b\right)\left(b-c\right)\left(c-a\right)$

コード(Emacs)

Python 3

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

a, b, c = symbols('a, b, c')
XS = [
[a, 1, 1, 1, a, 1, 1, 1, a],
[1, a, b, a, 1, 1, b, 1, 1],
[a, b, c, b, c, a, c, a, b],
[1, 1, 1, a, b, c, a ** 2, b ** 2, c ** 2]
]

for i, t in enumerate(XS, 1):
print(f'({i})')
X = Matrix(t).reshape(3, 3)
d = X.det()
for s in [X, d, d.factor()]:
pprint(s)
print()
print()


$./sample29.py (1) ⎡a 1 1⎤ ⎢ ⎥ ⎢1 a 1⎥ ⎢ ⎥ ⎣1 1 a⎦ 3 a - 3⋅a + 2 2 (a - 1) ⋅(a + 2) (2) ⎡1 a b⎤ ⎢ ⎥ ⎢a 1 1⎥ ⎢ ⎥ ⎣b 1 1⎦ 2 2 - a + 2⋅a⋅b - b 2 -(a - b) (3) ⎡a b c⎤ ⎢ ⎥ ⎢b c a⎥ ⎢ ⎥ ⎣c a b⎦ 3 3 3 - a + 3⋅a⋅b⋅c - b - c ⎛ 2 2 2⎞ -(a + b + c)⋅⎝a - a⋅b - a⋅c + b - b⋅c + c ⎠ (4) ⎡1 1 1 ⎤ ⎢ ⎥ ⎢a b c ⎥ ⎢ ⎥ ⎢ 2 2 2⎥ ⎣a b c ⎦ 2 2 2 2 2 2 - a ⋅b + a ⋅c + a⋅b - a⋅c - b ⋅c + b⋅c -(a - b)⋅(a - c)⋅(b - c)$