## 2019年7月8日月曜日

### 数学 - Python - 解析学 - 級数 - テイラーの公式 - 三角関数(余弦)、累乗(べき乗、立方)、階乗、差、商、極限

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

コード

Python 3

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

print('40.')

x = symbols('x')
num = cos(x) - 1 + x ** 2 / factorial(2)
f = num / x ** 3
g = num / x ** 4
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, x ** 3, x ** 4, f, g,
(x, -1, 1),
ylim=(-1, 1),
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('sample40.png')


C:\Users\...>py sample40.py
40.
⎛ 2             ⎞
⎜x              ⎟
⎜── + cos(x) - 1⎟
⎜2              ⎟
lim ⎜───────────────⎟
x─→0⁺⎜        3      ⎟
⎝       x       ⎠

0

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

0

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

1/24

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

1/24

C:\Users\...>