## 2018年1月12日金曜日

### 数学 - Python - 線型代数 - 行列式 - 行列式の計算(三角関数(正弦、余弦))

1. $\begin{array}{}-{\mathrm{cos}}^{2}\alpha {\mathrm{sin}}^{2}\beta -{\mathrm{sin}}^{2}\alpha {\mathrm{cos}}^{2}\beta -{\mathrm{cos}}^{2}\alpha {\mathrm{cos}}^{2}\beta -{\mathrm{sin}}^{2}\alpha {\mathrm{sin}}^{2}\beta \\ =-{\mathrm{cos}}^{2}\alpha \left({\mathrm{sin}}^{2}\beta +{\mathrm{cos}}^{2}\beta \right)-{\mathrm{sin}}^{2}\alpha \left({\mathrm{cos}}^{2}\beta +{\mathrm{sin}}^{2}\beta \right)\\ =-{\mathrm{cos}}^{2}\alpha -{\mathrm{sin}}^{2}\alpha \\ =-1\end{array}$

コード(Emacs)

Python 3

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

a, b = symbols('a, b')
M = Matrix([[cos(a) * cos(b), cos(a) * sin(b), - sin(a)],
[sin(a) * cos(b), sin(a) * sin(b), cos(a)],
[-sin(b), cos(b), 0]])

for t in [M, M.det(), M.det().factor()]:
pprint(t)
print()


$./sample4.py ⎡cos(a)⋅cos(b) sin(b)⋅cos(a) -sin(a)⎤ ⎢ ⎥ ⎢sin(a)⋅cos(b) sin(a)⋅sin(b) cos(a) ⎥ ⎢ ⎥ ⎣ -sin(b) cos(b) 0 ⎦ 2 2 2 2 2 2 2 2 - sin (a)⋅sin (b) - sin (a)⋅cos (b) - sin (b)⋅cos (a) - cos (a)⋅cos (b) ⎛ 2 2 ⎞ ⎛ 2 2 ⎞ -⎝sin (a) + cos (a)⎠⋅⎝sin (b) + cos (b)⎠$