## 2018年2月15日木曜日

### 数学 - Python - 線型代数 - 行列式 - 余因子行列と逆行列(ルート(平方根)、逆数)

1. 余因子。

$\begin{array}{}{\Delta }_{11}={\left(-1\right)}^{1+1}\left(-\frac{1}{2}\right)=-\frac{1}{2}\\ {\Delta }_{12}={\left(-1\right)}^{1+2}\left(-\frac{1}{2}\right)=\frac{1}{2}\\ {\Delta }_{13}={\left(-1\right)}^{1+3}\left(\frac{1}{2\sqrt{2}}+\frac{1}{2\sqrt{2}}\right)=\frac{1}{\sqrt{2}}\\ {\Delta }_{21}={\left(-1\right)}^{2+1}\left(-\frac{1}{2}\right)=\frac{1}{2}\\ {\Delta }_{22}={\left(-1\right)}^{2+2}\left(-\frac{1}{2}\right)=-\frac{1}{2}\\ {\Delta }_{23}={\left(-1\right)}^{2+3}\left(-\frac{1}{2\sqrt{2}}-\frac{1}{2\sqrt{2}}\right)=\frac{2}{2\sqrt{2}}=\frac{1}{\sqrt{2}}\\ {\Delta }_{31}={\left(-1\right)}^{3+1}\left(\frac{1}{2\sqrt{2}}+\frac{1}{2\sqrt{2}}\right)=\frac{1}{\sqrt{2}}\\ {\Delta }_{32}={\left(-1\right)}^{3+2}\left(-\frac{1}{2\sqrt{2}}-\frac{1}{2\sqrt{2}}\right)=\frac{1}{\sqrt{2}}\\ {\Delta }_{33}={\left(-1\right)}^{3+3}\left(\frac{1}{4}-\frac{1}{4}\right)=0\end{array}$

行列式。

$\mathrm{det}A=\left(\frac{1}{4}+\frac{1}{4}\right)-\left(-\frac{1}{4}-\frac{1}{4}\right)=1$

よって、求める逆行列は、

${A}^{-1}=\left(\begin{array}{ccc}-\frac{1}{2}& \frac{1}{2}& \frac{1}{\sqrt{2}}\\ \frac{1}{2}& -\frac{1}{2}& \frac{1}{\sqrt{2}}\\ \frac{1}{\sqrt{2}}& \frac{1}{\sqrt{2}}& 0\end{array}\right)$

コード(Emacs)

Python 3

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

A = Matrix([[-Rational(1, 2), Rational(1, 2), 1 / sqrt(2)],
[Rational(1, 2), -Rational(1, 2), 1 / sqrt(2)],
[1 / sqrt(2), 1 / sqrt(2), 0]])
A1 = Matrix([[-Rational(1, 2), Rational(1, 2), 1 / sqrt(2)],
[Rational(1, 2), -Rational(1, 2), 1 / sqrt(2)],
[1 / sqrt(2), 1 / sqrt(2), 0]])
for t in [A, A1, A * A1, A ** -1]:
pprint(t.expand())
print()


$./sample3.py ⎡ √2⎤ ⎢-1/2 1/2 ──⎥ ⎢ 2 ⎥ ⎢ ⎥ ⎢ √2⎥ ⎢1/2 -1/2 ──⎥ ⎢ 2 ⎥ ⎢ ⎥ ⎢ √2 √2 ⎥ ⎢ ── ── 0 ⎥ ⎣ 2 2 ⎦ ⎡ √2⎤ ⎢-1/2 1/2 ──⎥ ⎢ 2 ⎥ ⎢ ⎥ ⎢ √2⎥ ⎢1/2 -1/2 ──⎥ ⎢ 2 ⎥ ⎢ ⎥ ⎢ √2 √2 ⎥ ⎢ ── ── 0 ⎥ ⎣ 2 2 ⎦ ⎡1 0 0⎤ ⎢ ⎥ ⎢0 1 0⎥ ⎢ ⎥ ⎣0 0 1⎦ ⎡ √2⎤ ⎢-1/2 1/2 ──⎥ ⎢ 2 ⎥ ⎢ ⎥ ⎢ √2⎥ ⎢1/2 -1/2 ──⎥ ⎢ 2 ⎥ ⎢ ⎥ ⎢ √2 √2 ⎥ ⎢ ── ── 0 ⎥ ⎣ 2 2 ⎦$