## 2019年11月30日土曜日

### 数学 - Python - 円の中にひそむ関数 - 三角関数 - 加法定理 - 三角関数の諸公式 - 正弦と余弦、2倍角、不等式の解、2次、因数分解

1. $\begin{array}{l}0\le \theta <2\pi \\ \mathrm{sin}\theta \ge \mathrm{cos}2\theta \\ \mathrm{sin}\theta -\left({\mathrm{cos}}^{2}\theta -{\mathrm{sin}}^{2}\theta \right)\ge 0\\ \mathrm{sin}\theta -\left(1-2{\mathrm{sin}}^{2}\theta \right)\ge 0\\ 2{\mathrm{sin}}^{2}\theta +\mathrm{sin}\theta -1\ge 0\\ \left(2\mathrm{sin}\theta -1\right)\left(\mathrm{sin}\theta +1\right)\ge 0\\ \mathrm{sin}\theta \le -1,\frac{1}{2}\le \mathrm{sin}\theta \\ \theta =\frac{3}{2}\pi ,\frac{\pi }{6}\le \theta \le \frac{5}{6}\pi \end{array}$

2. $\begin{array}{l}\mathrm{cos}2\theta -3\mathrm{cos}\theta -1>0\\ {\mathrm{cos}}^{2}\theta -{\mathrm{sin}}^{2}\theta -3\mathrm{cos}\theta -1>0\\ 2{\mathrm{cos}}^{2}\theta -1-3\mathrm{cos}\theta -1>0\\ 2{\mathrm{cos}}^{2}\theta -3\mathrm{cos}\theta -2>0\\ \left(2\mathrm{cos}\theta +1\right)\left(\mathrm{cos}\theta -2\right)>0\\ \mathrm{cos}\theta <-\frac{1}{2},2<\mathrm{cos}\theta \\ \frac{2}{3}\pi <\theta <\frac{4}{3}\pi \end{array}$

コード

#!/usr/bin/env python3
from sympy import pprint, symbols, sin, cos, solveset, pi, Interval, plot
from sympy.solvers.inequalities import solve_univariate_inequality

print('31.')

theta = symbols('θ')
domain = Interval.Ropen(0, 2 * pi)
inequalities = [sin(theta) >= cos(2 * theta),
cos(2 * theta) - 3 * cos(theta) - 1 > 0]

for i, inequality in enumerate(inequalities, 1):
print(f'({i})')
pprint(solve_univariate_inequality(inequality, theta, domain=domain))

p = plot(sin(theta), cos(2 * theta), cos(2 * theta) - 3 * cos(theta) - 1,
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'sample31.png')

% ./sample31.py
31.
(1)
⎛π           5⋅π⎞       3⋅π
⎜─ ≤ θ ∧ θ ≤ ───⎟ ∨ θ = ───
⎝6            6 ⎠        2
(2)
2⋅π           4⋅π
─── < θ ∧ θ < ───
3             3
%