## 2019年6月21日金曜日

### 数学 - Python - 解析学 - 級数 - テイラーの公式 - 指数関数、累乗(べき乗、平方)、極限

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

コード

Python 3

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

print('24.')

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

for dir in ['+', '-']:
l = Limit(f, x, 0, dir=dir)
for o in [l, l.doit()]:
pprint(o)
print()

p = plot(exp(x), exp(-x), exp(x) + exp(-x), exp(x) + exp(-x) - 2, x ** 2, f,
(x, -5, 5),
ylim=(0, 10),
legend=True,
show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
o.line_color = color

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


C:\Users\...>py sample24.py
24.
⎛ x        -x⎞
⎜ℯ  - 2 + ℯ  ⎟
lim ⎜────────────⎟
x─→0⁺⎜      2     ⎟
⎝     x      ⎠

1

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

1

C:\Users\...>