## 2017年12月8日金曜日

### 数学 - Python - 線型代数 - 複素数、複素ベクトル空間 - 極形式(ド・モアブルの公式、三角関数(正弦、余弦)、倍角、実部、虚部)

1. $\begin{array}{}{\left(\mathrm{cos}\phi +i\mathrm{sin}\phi \right)}^{3}=\mathrm{cos}\left(3\phi \right)+i\mathrm{sin}\left(3\phi \right)\\ {\mathrm{cos}}^{3}\phi +3i\mathrm{cos}\phi \mathrm{sin}\phi -3\mathrm{cos}\phi {\mathrm{sin}}^{2}\phi -i{\mathrm{sin}}^{3}\phi =\mathrm{cos}\left(3\phi \right)+i\mathrm{sin}\left(3\phi \right)\\ \mathrm{cos}\left(3\phi \right)={\mathrm{cos}}^{3}\phi -3\mathrm{cos}\phi {\mathrm{sin}}^{2}\phi \end{array}$
$\begin{array}{}{\left(\mathrm{cos}\phi +i\mathrm{sin}\phi \right)}^{4}=\mathrm{cos}\left(4\phi \right)+i\mathrm{sin}\left(4\phi \right)\\ \mathrm{sin}\left(4\phi \right)=4{\mathrm{cos}}^{3}\phi \mathrm{sin}\phi -4\mathrm{cos}\phi {\mathrm{sin}}^{3}\phi \end{array}$
$\begin{array}{}{\left(\mathrm{cos}\phi +i\mathrm{sin}\phi \right)}^{5}=\mathrm{cos}\left(5\phi \right)+i\mathrm{sin}\left(5\phi \right)\\ \mathrm{cos}\left(5\phi \right)={\mathrm{cos}}^{5}\phi -10{\mathrm{cos}}^{3}\phi {\mathrm{sin}}^{2}\phi +5\mathrm{cos}\phi {\mathrm{sin}}^{4}\phi \end{array}$

コード(Emacs)

Python 3

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

x = symbols('x')
n = symbols('n', integer=True)
eq = (cos(x) + I * sin(x)) ** n

for n0 in range(3, 6):
eq0 = eq.subs({n: n0})
for t in [eq0, eq0.expand()]:
pprint(t)
print()
print()


$./sample4.py 3 (ⅈ⋅sin(x) + cos(x)) 3 2 2 3 - ⅈ⋅sin (x) - 3⋅sin (x)⋅cos(x) + 3⋅ⅈ⋅sin(x)⋅cos (x) + cos (x) 4 (ⅈ⋅sin(x) + cos(x)) 4 3 2 2 3 4 sin (x) - 4⋅ⅈ⋅sin (x)⋅cos(x) - 6⋅sin (x)⋅cos (x) + 4⋅ⅈ⋅sin(x)⋅cos (x) + cos (x ) 5 (ⅈ⋅sin(x) + cos(x)) 5 4 3 2 2 3 ⅈ⋅sin (x) + 5⋅sin (x)⋅cos(x) - 10⋅ⅈ⋅sin (x)⋅cos (x) - 10⋅sin (x)⋅cos (x) + 5⋅ⅈ 4 5 ⋅sin(x)⋅cos (x) + cos (x)$