## 2017年12月23日土曜日

### 数学 - Python - もう１つの数学の基盤 - 行列と行列式 – 連立1次方程式と行列式 - n = 3 の場合(行列の積の行列式と行列式の積)

1. $\left(\begin{array}{cc}aa\text{'}+bc\text{'}& ab\text{'}+bd\text{'}\\ ca\text{'}+dc\text{'}& cb\text{'}+dd\text{'}\end{array}\right)=\left(\begin{array}{cc}p& q\\ r& s\end{array}\right)$
$\begin{array}{}p=aa\text{'}+bc\text{'}\\ q=ab\text{'}+bd\text{'}\\ r=ca\text{'}+dc\text{'}\\ s=cb\text{'}+dd\text{'}\end{array}$
$\begin{array}{}ps-qr\\ =\left(aa\text{'}+bc\text{'}\right)\left(cb\text{'}+dd\text{'}\right)-\left(ab\text{'}+bd\text{'}\right)\left(ca\text{'}+dc\text{'}\right)\\ =aca\text{'}b\text{'}+ada\text{'}d\text{'}+bcb\text{'}c\text{'}+bdc\text{'}d\text{'}-aca\text{'}b\text{'}-adb\text{'}c\text{'}-bca\text{'}d\text{'}-bdc\text{'}d\text{'}\\ =ada\text{'}d\text{'}+bcb\text{'}c\text{'}-adb\text{'}c\text{'}-bca\text{'}d\text{'}\end{array}$
$\begin{array}{}\left(ad-bc\right)\left(a\text{'}d\text{'}-b\text{'}c\text{'}\right)\\ =ada\text{'}d\text{'}+bcb\text{'}c\text{'}-adb\text{'}c\text{'}-bca\text{'}d\text{'}\end{array}$

よって、

$ps-qr=\left(ad-bc\right)\left(a\text{'}d\text{'}-b\text{'}c\text{'}\right)$

ゆえに

$\mathrm{det}\left(AB\right)=\mathrm{det}A\mathrm{det}B$

コード(Emacs)

Python 3

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

a1, b1, c1, d1, a2, b2, c2, d2, p, q, r, s = symbols(
'a1, b1, c1, d1, a2, b2, c2, d2, p, q, r, s')

A = Matrix([[a1, b1],
[c1, d1]])
B = Matrix([[a2, b2],
[c2, d2]])
AB = A * B

for t in [A, B, AB]:
for s in [t, t.det()]:
pprint(s)
print()
print()

print(AB.det().expand() == (A.det() * B.det()).expand())


$./sample38.py ⎡a₁ b₁⎤ ⎢ ⎥ ⎣c₁ d₁⎦ a₁⋅d₁ - b₁⋅c₁ ⎡a₂ b₂⎤ ⎢ ⎥ ⎣c₂ d₂⎦ a₂⋅d₂ - b₂⋅c₂ ⎡a₁⋅a₂ + b₁⋅c₂ a₁⋅b₂ + b₁⋅d₂⎤ ⎢ ⎥ ⎣a₂⋅c₁ + c₂⋅d₁ b₂⋅c₁ + d₁⋅d₂⎦ (a₁⋅a₂ + b₁⋅c₂)⋅(b₂⋅c₁ + d₁⋅d₂) - (a₁⋅b₂ + b₁⋅d₂)⋅(a₂⋅c₁ + c₂⋅d₁) True$