## 2019年6月22日土曜日

### 数学 - Python - 解析学 - 級数 - テイラーの公式 - 指数関数、三角関数(正弦)、極限

1. $\begin{array}{l}\frac{d}{\mathrm{dx}}\left({e}^{x}+{e}^{-x}-2\right)\\ ={e}^{x}-{e}^{-x}\\ \frac{{d}^{2}}{{\mathrm{dx}}^{2}}\left({e}^{x}+{e}^{-x}-2\right)\\ ={e}^{x}+{e}^{-x}\\ \frac{{d}^{3}}{{\mathrm{dx}}^{3}}\left({e}^{x}+{e}^{-x}-2\right)\\ ={e}^{x}-{e}^{-x}\\ {e}^{x}+{e}^{-x}-2\\ =\frac{2}{2!}{x}^{2}+\frac{2}{4!}{x}^{2}+\dots \\ \mathrm{sin}x=x-\frac{1}{3!}{x}^{2}+\frac{1}{5!}{x}^{5}-\dots \\ \underset{x\to 0}{\mathrm{lim}}\frac{{e}^{x}+{e}^{-x}-2}{x\mathrm{sin}x}=1\end{array}$

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, plot, Limit, exp, sin

print('25.')

x = symbols('x')
f = (exp(x) + exp(-x) - 2) / (x * sin(x))

for dir in ['+', '-']:
l = Limit(f, x, 0, dir=dir)
for o in [l, l.doit()]:
pprint(o)
print()
fs = [exp(x), exp(-x), exp(x) + exp(-x), exp(x) + exp(-x) - 2,
x, sin(x), x * sin(x),
f]
p = plot(*fs,
(x, -5, 5),
ylim=(-5, 5),
legend=False,
show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o in [fs, colors]:
pprint(o)
print()
for o, color in zip(p, colors):
o.line_color = color

p.show()
p.save('sample25.png')


C:\Users\...>py sample25.py
25.
⎛ x        -x⎞
⎜ℯ  - 2 + ℯ  ⎟
lim ⎜────────────⎟
x─→0⁺⎝  x⋅sin(x)  ⎠

1

⎛ x        -x⎞
⎜ℯ  - 2 + ℯ  ⎟
lim ⎜────────────⎟
x─→0⁻⎝  x⋅sin(x)  ⎠

1

⎡                                                       x        -x⎤
⎢ x   -x   x    -x   x        -x                       ℯ  - 2 + ℯ  ⎥
⎢ℯ , ℯ  , ℯ  + ℯ  , ℯ  - 2 + ℯ  , x, sin(x), x⋅sin(x), ────────────⎥
⎣                                                        x⋅sin(x)  ⎦

[red, green, blue, brown, orange, purple, pink, gray, skyblue, yellow]

C:\Users\...>