## 2018年1月16日火曜日

### 数学 - Python - 線型代数 - 行列式 - 行列式の計算(4-次正方行列、複素数、等式)

1. $\begin{array}{}\mathrm{det}\left(\begin{array}{cccc}0& 1& 0& 0\\ -{x}^{2}& x& 1& 0\\ 0& 0& x& 1\\ 1& 0& 0& x\end{array}\right)\end{array}=\mathrm{det}\left(\begin{array}{cccc}1& 0& 0& 0\\ 0& {x}^{2}& 1& 0\\ 0& 0& x& 1\\ 0& -1& 0& x\end{array}\right)\\ ={x}^{4}-1$
$\begin{array}{}{x}^{4}-1=0\\ \left({x}^{2}+1\right)\left({x}^{2}-1\right)=0\\ \left({x}^{2}+1\right)\left(x+1\right)\left(x-1\right)=0\\ x=±1,±i\end{array}$

2. $\begin{array}{}\mathrm{det}\left(\begin{array}{cccc}0& 1& 0& 0\\ -{x}^{2}& x& x& 1-{x}^{2}\\ 1-{x}^{2}& x& x& -{x}^{2}\\ x& 0& 1& x\end{array}\right)\end{array}=\mathrm{det}\left(\begin{array}{ccc}{x}^{2}& x& 1-{x}^{2}\\ {x}^{2}-1& x& -{x}^{2}\\ -x& 1& x\end{array}\right)\\ =\mathrm{det}\left(\begin{array}{ccc}2{x}^{2}& x& 1-2{x}^{2}\\ 2{x}^{2}-1& x& -2{x}^{2}\end{array}\right)\\ 010\\ =\left(1-2{x}^{2}\right)\left(2{x}^{2}-1\right)-\left(-4{x}^{4}\right)\\ =-4{x}^{4}+4{x}^{2}-1+4{x}^{4}\\ =4{x}^{2}-1$
$\begin{array}{}4{x}^{2}-1=0\\ \left(2x+1\right)\left(2x-1\right)=0\\ x=±\frac{1}{2}\end{array}$

コード(Emacs)

Python 3

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

x = symbols('x')
A = Matrix([x, 1, 0, 0, 0, x, 1, 0, 0, 0, x, 1, 1, 0, 0, x]).reshape(4, 4)
B = Matrix([x, 1, 0, x, 0, x, x, 1, 1, x, x, 0, x, 0, 1, x]).reshape(4, 4)

for i, M in enumerate([A, B]):
print(f'({chr(ord("a") + i)})')
for t in [M, M.det(), solve(M.det())]:
pprint(t)
print()
print()


$./sample5.py (a) ⎡x 1 0 0⎤ ⎢ ⎥ ⎢0 x 1 0⎥ ⎢ ⎥ ⎢0 0 x 1⎥ ⎢ ⎥ ⎣1 0 0 x⎦ 4 x - 1 [-1, 1, -ⅈ, ⅈ] (b) ⎡x 1 0 x⎤ ⎢ ⎥ ⎢0 x x 1⎥ ⎢ ⎥ ⎢1 x x 0⎥ ⎢ ⎥ ⎣x 0 1 x⎦ 2 4⋅x - 1 [-1/2, 1/2]$