## 2019年2月8日金曜日

### 数学 - Python - 解析学 - 積分 - 積分の応用 - 面積(三角関数(正弦)、結び、ハート形、極座標表示)

1. $\begin{array}{}1+2\mathrm{sin}\theta =0\\ \mathrm{sin}\theta =-\frac{1}{2}\\ \theta =-\frac{1}{6}\pi ,-\frac{5}{6}\pi \\ \int \frac{\pi {r}^{2}}{2\pi }d\theta \\ =\frac{1}{2}\int {\left(1+2\mathrm{sin}\theta \right)}^{2}d\theta \\ =\frac{1}{2}\int \left(1+4\mathrm{sin}\theta +4{\mathrm{sin}}^{2}\theta \right)d\theta \\ =\frac{1}{2}\left(\theta -4\mathrm{cos}\theta +4\left(-\frac{1}{2}\mathrm{sin}\theta \mathrm{cos}\theta +\frac{1}{2}\theta \right)\right)\\ =\frac{1}{2}\theta -2\mathrm{cos}\theta -\mathrm{sin}\theta \mathrm{cos}\theta +\theta \\ {\left[\frac{1}{2}\theta -2\mathrm{cos}\theta -\mathrm{sin}\theta \mathrm{cos}\theta +\theta \right]}_{\left(-\frac{\pi }{6}\right)}^{\left(\frac{7}{6}\pi \right)}\\ =\frac{3}{2}·\frac{8}{6}\pi -2\left(-\frac{\sqrt{3}}{2}-\frac{\sqrt{3}}{2}\right)-\left(\left(-\frac{1}{2}\right)\left(-\frac{\sqrt{3}}{2}\right)-\left(-\frac{1}{2}\right)\left(\frac{\sqrt{3}}{2}\right)\right)\\ =2\pi +2\sqrt{3}-\frac{\sqrt{3}}{2}\\ =2\pi +\frac{3\sqrt{3}}{2}\end{array}$

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, Integral, cos, sin, pi, exp, sqrt
from sympy.plotting import plot_parametric

theta = symbols('θ')
r = 1 + 2 * sin(theta)
x = r * cos(theta)
y = r * sin(theta)

I = Integral(r ** 2 / 2, (theta, - pi / 6, 7 * pi / 6))
for o in [I, I.doit()]:
pprint(o.simplify())
print()

p = plot_parametric((x, y, (theta, 0, pi / 2)),
(x, y, (theta, pi / 2, pi)),
(x, y, (theta, pi, 7 * pi / 6)),
(x, y, (theta, 7 * pi / 6, 3 * pi / 2)),
(x, y, (theta,  3 * pi / 2, 11 * pi / 6)),
(x, y, (theta, 11 * pi / 6, 2 * pi)),
show=False)

colors = ['red', 'green', 'blue', 'brown', 'orange', 'pink']
for i, s in enumerate(p):
s.line_color = colors[i]
p.save('sample7.png')

C:\Users\...> py -3 sample7.py
7⋅π
───
6
⌠
⎮                2
⎮  (2⋅sin(θ) + 1)
⎮  ─────────────── dθ
⎮         2
⌡
-π
───
6

3⋅√3
──── + 2⋅π
2

C:\Users\...>