## 2019年1月27日日曜日

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

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

コード

Python 3

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

theta = symbols('θ')
r = 3 * 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()

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

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


$python3 sample16.py π ─ 4 ⌠ ⎮ _____________________________ ⎮ ╱ 2 ⎮ ╱ 2 ⎛d ⎞ ⎮ ╱ 9⋅cos (θ) + ⎜──(3⋅cos(θ))⎟ dθ ⎮ ╲╱ ⎝dθ ⎠ ⌡ 0 3⋅π ─── 4$