## 2019年6月24日月曜日

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

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

コード

Python 3

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

print('27.')

x = symbols('x')
f = (sin(x) - x) / x ** 3

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

p = plot(sin(x), -x, sin(x) - x, x ** 3, f,
(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('sample27.png')


C:\Users\...>py sample27.py
27.
⎛-x + sin(x)⎞
lim ⎜───────────⎟
x─→0⁺⎜      3    ⎟
⎝     x     ⎠

-1/6

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

-1/6

C:\Users\...>