## 2019年7月10日水曜日

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

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

コード

Python 3

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

print('43.')

x = symbols('x')
num = sin(x) - exp(x) + 1
den1 = x
den2 = x ** 2
f = num / den1
g = num / den2
for h in [f, g]:
for d in ['+', '-']:
l = Limit(h, x, 0, dir=d)
for o in [l, l.doit()]:
pprint(o)
print()

p = plot(num, den1, den2, f, g,
(x, -5, 5),
ylim=(-5, 5),
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('sample43.png')


C:\Users\...>py sample43.py
43.
⎛   x             ⎞
⎜- ℯ  + sin(x) + 1⎟
lim ⎜─────────────────⎟
x─→0⁺⎝        x        ⎠

0

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

0

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

-1/2

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

-1/2

C:\Users\...>