## 2019年2月6日水曜日

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

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

I = Integral(r ** 2 / 2, (theta, 0, 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')

C:\Users\...> py -3 sample5.py
π
⌠
⎮    4
⎮ sin (θ)
⎮ ─────── dθ
⎮    2
⌡
0

3⋅π
───
16

C:\Users\...>