## 2019年11月20日水曜日

### 数学 - Python - 円の中にひそむ関数 - 三角関数 - 加法定理 - 三角関数の合成 - 不等式の解、正弦と余弦

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

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

コード

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

print('24.')

theta = symbols('θ')
ineqs = [sin(theta) > cos(theta),
sqrt(3) * cos(theta) - sin(theta) <= 1]

for i, ineq in enumerate(ineqs, 1):
print(f'({i})')
pprint(solve_univariate_inequality(
ineq, theta, domain=Interval.Ropen(0, 2 * pi)))

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

% ./sample24.py
24.
(1)
π           5⋅π
─ < θ ∧ θ < ───
4            4
(2)
⎛             ⎛   ⎛        ___________________________________________________
⎜             ⎜   ⎜       ╱      ⎛     _______       ⎞        ⎛     _______
⎜             ⎜   ⎜      ╱       ⎜    ╱   ⅈ⋅π   -ⅈ⋅π ⎟        ⎜    ╱   ⅈ⋅π   -
⎜             ⎜   ⎜     ╱        ⎜   ╱    ───   ─────⎟        ⎜   ╱    ───   ─
⎜             ⎜   ⎜    ╱         ⎜  ╱      3      3  ⎟       2⎜  ╱      3
⎜             ⎜   ⎜   ╱     √3⋅im⎝╲╱    -ℯ    ⋅ℯ     ⎠   3⋅re ⎝╲╱    -ℯ    ⋅ℯ
⎜θ < 2⋅π ∧ -ⅈ⋅⎜log⎜  ╱      ────────────────────────── + ─────────────────────
⎜             ⎜   ⎝╲╱                   4                            4
⎜             ⎜
⎜             ⎜
⎜             ⎜
⎝             ⎝

___________________________________________________________________⎞
⎞           ⎛     _______       ⎞        ⎛     _______       ⎞ ⎟         ⎛
ⅈ⋅π ⎟           ⎜    ╱   ⅈ⋅π   -ⅈ⋅π ⎟        ⎜    ╱   ⅈ⋅π   -ⅈ⋅π ⎟ ⎟         ⎜
────⎟           ⎜   ╱    ───   ─────⎟        ⎜   ╱    ───   ─────⎟ ⎟         ⎜
3  ⎟           ⎜  ╱      3      3  ⎟       2⎜  ╱      3      3  ⎟ ⎟         ⎜
⎠   1   3⋅re⎝╲╱    -ℯ    ⋅ℯ     ⎠   3⋅im ⎝╲╱    -ℯ    ⋅ℯ     ⎠ ⎟         ⎜
───── + ─ - ───────────────────────── + ────────────────────────── ⎟ - ⅈ⋅atan⎜
4               4                           4              ⎠         ⎜
⎜
⎜
⎜
⎝

⎞    ⎞                  ⎛   ⎛        ___
⎛            ⎛     _______       ⎞⎞ ⎞⎟    ⎟                  ⎜   ⎜       ╱
⎜            ⎜    ╱   ⅈ⋅π   -ⅈ⋅π ⎟⎟ ⎟⎟    ⎟                  ⎜   ⎜      ╱
⎜            ⎜   ╱    ───   ─────⎟⎟ ⎟⎟    ⎟                  ⎜   ⎜     ╱
⎜            ⎜  ╱      3      3  ⎟⎟ ⎟⎟    ⎟                  ⎜   ⎜    ╱
-⎝-1 - 2⋅√3⋅im⎝╲╱    -ℯ    ⋅ℯ     ⎠⎠ ⎟⎟    ⎟                  ⎜   ⎜   ╱     √3
─────────────────────────────────────⎟⎟ < θ⎟ ∨ θ = 0 ∨ θ = -ⅈ⋅⎜log⎜  ╱      ──
⎛     _______       ⎞  ⎟⎟    ⎟                  ⎜   ⎝╲╱
⎜    ╱   ⅈ⋅π   -ⅈ⋅π ⎟  ⎟⎟    ⎟                  ⎜
⎜   ╱    ───   ─────⎟  ⎟⎟    ⎟                  ⎜
⎜  ╱      3      3  ⎟  ⎟⎟    ⎟                  ⎜
√3 - 2⋅√3⋅re⎝╲╱    -ℯ    ⋅ℯ     ⎠  ⎠⎠    ⎠                  ⎝

______________________________________________________________________________
⎛     _______       ⎞        ⎛     _______       ⎞           ⎛     _______
⎜    ╱   ⅈ⋅π   -ⅈ⋅π ⎟        ⎜    ╱   ⅈ⋅π   -ⅈ⋅π ⎟           ⎜    ╱   ⅈ⋅π
⎜   ╱    ───   ─────⎟        ⎜   ╱    ───   ─────⎟           ⎜   ╱    ───
⎜  ╱      3      3  ⎟       2⎜  ╱      3      3  ⎟           ⎜  ╱      3
⋅im⎝╲╱    -ℯ    ⋅ℯ     ⎠   3⋅re ⎝╲╱    -ℯ    ⋅ℯ     ⎠   1   3⋅re⎝╲╱    -ℯ    ⋅
──────────────────────── + ────────────────────────── + ─ - ──────────────────
4                            4                4               4

_____________________________________⎞
⎞        ⎛     _______       ⎞ ⎟         ⎛ ⎛            ⎛     _______
-ⅈ⋅π ⎟        ⎜    ╱   ⅈ⋅π   -ⅈ⋅π ⎟ ⎟         ⎜ ⎜            ⎜    ╱   ⅈ⋅π   -
─────⎟        ⎜   ╱    ───   ─────⎟ ⎟         ⎜ ⎜            ⎜   ╱    ───   ─
3  ⎟       2⎜  ╱      3      3  ⎟ ⎟         ⎜ ⎜            ⎜  ╱      3
ℯ     ⎠   3⋅im ⎝╲╱    -ℯ    ⋅ℯ     ⎠ ⎟         ⎜-⎝-1 - 2⋅√3⋅im⎝╲╱    -ℯ    ⋅ℯ
─────── + ────────────────────────── ⎟ - ⅈ⋅atan⎜──────────────────────────────
4              ⎠         ⎜              ⎛     _______
⎜              ⎜    ╱   ⅈ⋅π   -
⎜              ⎜   ╱    ───   ─
⎜              ⎜  ╱      3
⎝  √3 - 2⋅√3⋅re⎝╲╱    -ℯ    ⋅ℯ

⎞
⎞⎞ ⎞⎟
ⅈ⋅π ⎟⎟ ⎟⎟
────⎟⎟ ⎟⎟
3  ⎟⎟ ⎟⎟
⎠⎠ ⎟⎟
───────⎟⎟
⎞  ⎟⎟
ⅈ⋅π ⎟  ⎟⎟
────⎟  ⎟⎟
3  ⎟  ⎟⎟
⎠  ⎠⎠
%