## 2019年11月25日月曜日

### 数学 - Python - 円の中にひそむ関数 - 三角関数 - 加法定理 - 三角関数の諸公式の正接 - 正弦と余弦、2倍角、半角

1. $\begin{array}{l}2n\pi \le \alpha \le 2n\pi +\frac{\pi }{2}\\ \mathrm{cos}\left(2\alpha \right)\\ ={\mathrm{cos}}^{2}\alpha -{\mathrm{sin}}^{2}\alpha \\ =2{\mathrm{cos}}^{2}\alpha -1\\ =\frac{2}{9}-1\\ =-\frac{7}{9}\\ \mathrm{sin}\left(2\alpha \right)\\ =\sqrt{1-{\mathrm{cos}}^{2}\left(2\alpha \right)}\\ =\sqrt{1-{\left(\frac{7}{9}\right)}^{2}}\\ =\sqrt{\frac{81-49}{{9}^{2}}}\\ =\frac{\sqrt{32}}{9}\\ =\frac{4\sqrt{2}}{9}\\ n\pi \le \frac{\alpha }{2}\le n\pi +\frac{\pi }{4}\\ {\mathrm{sin}}^{2}\left(\frac{\alpha }{2}\right)\\ =\frac{1-\mathrm{cos}\alpha }{2}\\ =\frac{1-\frac{1}{3}}{2}\\ =\frac{1}{3}\\ \mathrm{sin}\left(\frac{\alpha }{2}\right)=±\frac{1}{\sqrt{3}}\\ {\mathrm{cos}}^{2}\left(\frac{\alpha }{2}\right)\\ =\frac{\mathrm{cos}\alpha +1}{2}\\ =\frac{\frac{1}{3}+1}{2}\\ =\frac{2}{3}\\ \mathrm{cos}\left(\frac{\alpha }{2}\right)=±\sqrt{\frac{2}{3}}=±\frac{\sqrt{6}}{3}\end{array}$

コード

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

print('26.')

n = symbols('n', integer=True)
alpha = symbols('α')
alpha0 = [t for t in solve(
cos(alpha) - Rational(1, 3), alpha) if 0 <= t <= pi / 2][0]

for n in [2, Rational(1, 2)]:
for f in [sin, cos]:
t = f(n * alpha0)
for o in [t, float(t)]:
pprint(o)
print()

p = plot(*[f(n * alpha)
for n in [1, 2, Rational(1, 2)]
for f in [sin, cos]],
ylim=(-10, 10),
legend=True,
show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

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

p.show()
p.save(f'sample26.png')


% ./sample26.py
26.
sin(2⋅acos(1/3))

0.6285393610547089

cos(2⋅acos(1/3))

-0.7777777777777778

⎛acos(1/3)⎞
sin⎜─────────⎟
⎝    2    ⎠

0.5773502691896257

⎛acos(1/3)⎞
cos⎜─────────⎟
⎝    2    ⎠

0.816496580927726

%