## 2017年12月9日土曜日

### 数学 - Python - もう１つの数学の基盤 - 行列と行列式 – 行列式 - 3次の行列式(各列に関する展開式)

1. 第2列 に関する展開式。

$\begin{array}{}-{a}_{12}|\begin{array}{cc}{a}_{21}& {a}_{23}\\ {a}_{31}& {a}_{33}\end{array}|\end{array}+{a}_{22}|\begin{array}{cc}{a}_{11}& {a}_{13}\\ {a}_{31}& {a}_{33}\end{array}|-{a}_{23}|\begin{array}{cc}{a}_{11}& {a}_{13}\\ {a}_{21}& {a}_{23}\end{array}|=-{a}_{12}\left({a}_{21}{a}_{33}-{a}_{23}{a}_{31}\right)+{a}_{22}\left({a}_{11}{a}_{33}-{a}_{13}{a}_{31}\right)-{a}_{32}\left({a}_{11}{a}_{23}-{a}_{13}{a}_{21}\right)\\ =-{a}_{12}{a}_{21}{a}_{33}+{a}_{12}{a}_{23}{a}_{31}+{a}_{22}{a}_{11}{a}_{33}-{a}_{22}{a}_{13}{a}_{31}-{a}_{32}{a}_{11}{a}_{23}+{a}_{32}{a}_{13}{a}_{21}$

第3列に関する展開式。

$\begin{array}{}{a}_{13}|\begin{array}{cc}{a}_{21}& {a}_{22}\\ {a}_{31}& {a}_{32}\end{array}|\end{array}-{a}_{23}|\begin{array}{cc}{a}_{11}& {a}_{12}\\ {a}_{31}& {a}_{32}\end{array}|+{a}_{33}|\begin{array}{cc}{a}_{11}& {a}_{12}\\ {a}_{21}& {a}_{22}\end{array}|={a}_{13}\left({a}_{21}{a}_{32}-{a}_{22}{a}_{31}\right)-{a}_{23}\left({a}_{11}{a}_{32}-{a}_{12}{a}_{31}\right)+{a}_{33}\left({a}_{11}{a}_{22}-{a}_{12}{a}_{21}\right)\\ ={a}_{13}{a}_{21}{a}_{32}-{a}_{13}{a}_{22}{a}_{31}-{a}_{23}{a}_{11}{a}_{32}+{a}_{23}{a}_{12}{a}_{31}+{a}_{33}{a}_{11}{a}_{22}-{a}_{33}{a}_{12}{a}_{21}$

よって、結果6つの項が同じ項になることを確認できる。

コード(Emacs)

Python 3

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

a11, a12, a13, a21, a22, a23, a31, a32, a33 = symbols(
'a11, a12, a13, a21, a22, a23, a31, a32, a33')

A = Matrix([[a11, a12, a13],
[a21, a22, a23],
[a31, a32, a33]])

expr1 = -a12 * A[1:, 0::2].det() + a22 * A[::2, 0::2].det() - \
a32 * A[:2, 0::2].det()
expr2 = a13 * A[1:, 0:2].det() - a23 * A[::2, 0:2].det() + \
a33 * A[:2, 0:2].det()

for t in [A, A.det(), expr1, expr2, A.det().expand() == expr1.expand() == expr2.expand()]:
pprint(t)
print()


$./sample25.py ⎡a₁₁ a₁₂ a₁₃⎤ ⎢ ⎥ ⎢a₂₁ a₂₂ a₂₃⎥ ⎢ ⎥ ⎣a₃₁ a₃₂ a₃₃⎦ a₁₁⋅a₂₂⋅a₃₃ - a₁₁⋅a₂₃⋅a₃₂ - a₁₂⋅a₂₁⋅a₃₃ + a₁₂⋅a₂₃⋅a₃₁ + a₁₃⋅a₂₁⋅a₃₂ - a₁₃⋅a₂₂⋅ a₃₁ -a₁₂⋅(a₂₁⋅a₃₃ - a₂₃⋅a₃₁) + a₂₂⋅(a₁₁⋅a₃₃ - a₁₃⋅a₃₁) - a₃₂⋅(a₁₁⋅a₂₃ - a₁₃⋅a₂₁) a₁₃⋅(a₂₁⋅a₃₂ - a₂₂⋅a₃₁) - a₂₃⋅(a₁₁⋅a₃₂ - a₁₂⋅a₃₁) + a₃₃⋅(a₁₁⋅a₂₂ - a₁₂⋅a₂₁) True$