## 2019年1月21日月曜日

### 数学 - Python - 解析学 - 積分 - 積分の応用 - 曲線の長さ(指数関数)

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

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, Integral, Derivative, plot, sqrt, Rational
from sympy import exp

x = symbols('x')

f = Rational(1, 2) * (exp(x) + exp(-x))
I = Integral(sqrt(1 + Derivative(f, x, 1) ** 2), (x, -1, 0))

I1 = I.doit()
I2 = I1.doit()
for o in [I, I1, I2]:
pprint(o)
print()

p = plot((f, (x, -2, -1)),
(f, (x, -1, 0)),
(f, (x, 0, 2)),
legend=True,
show=False)
colors = ['red', 'green', 'blue']
for i, color in enumerate(colors):
p[i].line_color = color
p.save('sample10.png')


$python3 sample10.py 0 ⌠ ⎮ _____________________ ⎮ ╱ 2 ⎮ ╱ ⎛ ⎛ x -x⎞⎞ ⎮ ╱ ⎜d ⎜ℯ ℯ ⎟⎟ ⎮ ╱ ⎜──⎜── + ───⎟⎟ + 1 dx ⎮ ╲╱ ⎝dx⎝2 2 ⎠⎠ ⌡ -1 0 ⌠ ⎮ __________________ ⎮ ╱ 2⋅x -2⋅x ⎮ ╲╱ ℯ + 2 + ℯ dx ⌡ -1 ─────────────────────────── 2 0 ⌠ ⎮ __________________ ⎮ ╱ 2⋅x -2⋅x ⎮ ╲╱ ℯ + 2 + ℯ dx ⌡ -1 ─────────────────────────── 2$