## 2019年8月28日水曜日

### 数学 - Python - 解析学 - 各種の初等関数 - 三角関数 - 正弦、余弦、3倍角の公式

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

コード

Python 3

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

print('5.')

theta = symbols('θ')
p = plot(sin(theta), sin(3 * theta), cos(theta), cos(3 * theta),
(theta, -5, 5),
ylim=(-5, 5),
show=False,
legend=True)

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
o.line_color = color

p.show()
p.save('sample5.png')


C:\Users\...>py sample5.py
5.

C:\Users\...>