## 2019年1月29日火曜日

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

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

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

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

for o in [I.doit(), 4 * sin(pi / 8)]:
print(float(o))

p = plot_parametric((x, y, (theta, -pi, 0)),
(x, y, (theta, 0, pi / 4)),
(x, y, (theta, pi / 4, pi)),
show=False)

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


$python3 sample18.py π ─ 4 ⌠ ⎮ ___________________________________ ⎮ ╱ 2 ⎮ ╱ 2 ⎛d ⎞ ⎮ ╱ (cos(θ) + 1) + ⎜──(cos(θ) + 1)⎟ dθ ⎮ ╲╱ ⎝dθ ⎠ ⌡ 0 π ─ 4 ⌠ ⎮ ______________ ⎮ ╲╱ 2⋅cos(θ) + 2 dθ ⌡ 0 π ─ 4 ⌠ ⎮ ⎛θ⎞ 2⋅⎮ cos⎜─⎟ dθ ⎮ ⎝2⎠ ⌡ 0 _________ 2⋅╲╱ -√2 + 2 1.5307337294603591 1.5307337294603591$