## 2019年2月5日火曜日

### 数学 - Python - 解析学 - 積分 - 積分の応用 - 面積(三角関数(正弦)、累乗、倍角、極座標表示)

1. $\begin{array}{}\underset{0}{\overset{2\pi }{\int }}\frac{\pi {r}^{2}}{2\pi }d\theta \\ =\frac{1}{2}\underset{0}{\overset{2\pi }{\int }}{\left(2+\mathrm{sin}\left(2\theta \right)\right)}^{2}d\theta \\ =\frac{1}{2}\underset{0}{\overset{2\pi }{\int }}\left(4+4\mathrm{sin}\left(2\theta \right)+{\mathrm{sin}}^{2}\left(2\theta \right)\right)d\theta \\ =\frac{1}{2}{\left[4\theta -2\mathrm{cos}\left(2\theta \right)\right]}_{0}^{2\pi }+\frac{1}{2}\underset{0}{\overset{2\pi }{\int }}{\mathrm{sin}}^{2}\left(2\theta \right)d\theta \\ =\frac{1}{2}·8\pi +\frac{1}{2}\underset{0}{\overset{2\pi }{\int }}{\mathrm{sin}}^{2}\left(2\theta \right)d\theta \\ t=2\theta \\ \frac{\mathrm{dt}}{d\theta }=2\\ \int {\mathrm{sin}}^{2}t·\frac{1}{2}\mathrm{dt}\\ =\frac{1}{2}\left(-\mathrm{sin}t\mathrm{cos}t+\frac{1}{2}\int 1\mathrm{dt}\right)\\ =\frac{1}{2}\left(-\mathrm{sin}t\mathrm{cos}t+\frac{1}{2}t\right)\\ \theta =0,t=0\\ \theta =2\pi ,t=4\pi \\ \underset{0}{\overset{4\pi }{\int }}{\mathrm{sin}}^{2}t·\frac{1}{2}\mathrm{dt}\\ =\frac{1}{2}\left({\left[-\mathrm{sin}t\mathrm{cos}t\right]}_{0}^{4\pi }+\frac{1}{2}{\left[t\right]}_{0}^{4\pi }\right)\\ =\pi \\ 4\pi +\frac{1}{2}·\pi \\ =\frac{9}{2}\pi \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 = 2 + sin(2 * theta)
x = r * cos(theta)
y = r * sin(theta)

I = Integral(r ** 2 / 2, (theta, 0, 2 * pi))

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, 3 * pi / 2)),
(x, y, (theta, 3 * pi / 2, 2 * pi)),
show=False)

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


$python3 sample3.py 2⋅π ⌠ ⎮ ⎛ cos(θ) 1⎞ ⎮ ⎜- ────── + ─⎟ dθ ⎮ ⎝ 2 2⎠ ⌡ 0 π$