## 2019年7月2日火曜日

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

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

コード

Python 3

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

print('35.')

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

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

p = plot(sin(x), cos(x), -1, -x, sin(x) + cos(x) - 1 - x, x ** 2, 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('sample35.png')


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

-1/2

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

-1/2

C:\Users\...>