## 2019年1月30日水曜日

### 数学 - Python - 解析学 - 積分 - 積分の応用 - 曲線の長さ(三角関数(余弦)、半角、加法定理、極座標表示)

1. $\begin{array}{}\underset{0}{\overset{\pi }{\int }}\sqrt{{\left(1-\mathrm{cos}\theta \right)}^{2}+{\left(\frac{d}{d\theta }\left(1-\mathrm{cos}\theta \right)\right)}^{2}}d\theta \\ =\underset{0}{\overset{\pi }{\int }}\sqrt{1-2\mathrm{cos}\theta +{\mathrm{cos}}^{2}\theta +{\mathrm{sin}}^{2}\theta }d\theta \\ =\underset{0}{\overset{\pi }{\int }}\sqrt{2-2\mathrm{cos}\theta }d\theta \\ =\sqrt{2}\underset{0}{\overset{\pi }{\int }}\sqrt{1-\mathrm{cos}\left(\frac{\theta }{2}+\frac{\theta }{2}\right)}d\theta \\ =\sqrt{2}\underset{0}{\overset{\pi }{\int }}\sqrt{1-\left({\mathrm{cos}}^{2}\left(\frac{\theta }{2}\right)-{\mathrm{sin}}^{2}\left(\frac{\theta }{2}\right)\right)}d\theta \\ =\sqrt{2}\underset{0}{\overset{\pi }{\int }}\sqrt{2{\mathrm{sin}}^{2}\left(\frac{\theta }{2}\right)}d\theta \\ =2\underset{0}{\overset{\pi }{\int }}\mathrm{sin}\left(\frac{\theta }{2}\right)d\theta \\ =2{\left[-2\mathrm{cos}\left(\frac{\theta }{2}\right)\right]}_{0}^{\pi }\\ =-4\left(\mathrm{cos}\frac{\pi }{2}-\mathrm{cos}\theta \right)\\ =-4\left(0-1\right)\\ =4\end{array}$

コード

Python 3

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

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

I = Integral(sqrt(r ** 2 + Derivative(r, theta, 1) ** 2),
(theta, 0, pi))

for o in [I, I.doit()]:
pprint(o.simplify())
print()

I = 2 * Integral(sin(theta / 2), (theta, 0, pi))
for o in [I, I.doit()]:
pprint(o.simplify())
print()

p = plot_parametric((x, y, (theta, 0, pi)),
(x, y, (theta, pi, 2 * pi)),
show=False)

colors = ['red', 'green']
for i, color in enumerate(colors):
p[i].line_color = color
p.save('sample19.png')


$python3 sample19.py π ⌠ ⎮ ____________________________________ ⎮ ╱ 2 ⎮ ╱ 2 ⎛d ⎞ ⎮ ╱ (cos(θ) - 1) + ⎜──(-cos(θ) + 1)⎟ dθ ⎮ ╲╱ ⎝dθ ⎠ ⌡ 0 π ⌠ ⎮ _______________ ⎮ ╲╱ -2⋅cos(θ) + 2 dθ ⌡ 0 π ⌠ ⎮ ⎛θ⎞ 2⋅⎮ sin⎜─⎟ dθ ⎮ ⎝2⎠ ⌡ 0 4$