## 2019年5月20日月曜日

### 数学 - Python - 解析学 - 級数 - テイラーの公式 - 一意性定理(三角関数(余弦)、逆数)

1. $\begin{array}{l}\frac{d}{\mathrm{dx}}\frac{1}{\mathrm{cos}x}=\frac{\mathrm{sin}x}{{\mathrm{cos}}^{2}x}\\ \frac{{d}^{2}}{{\mathrm{dx}}^{2}}\frac{1}{\mathrm{cos}x}\\ =\frac{{\mathrm{cos}}^{3}x-\mathrm{sin}x\left(2\mathrm{cos}x\right)\left(-\mathrm{sin}x\right)}{{\mathrm{cos}}^{4}x}\\ =\frac{{\mathrm{cos}}^{3}x+2{\mathrm{sin}}^{2}x\mathrm{cos}x}{{\mathrm{cos}}^{4}x}\\ =\frac{{\mathrm{cos}}^{3}x+2\left(1-{\mathrm{cos}}^{2}x\right)\mathrm{cos}x}{{\mathrm{cos}}^{4}x}\\ =\frac{2\mathrm{cos}x-{\mathrm{cos}}^{3}x}{{\mathrm{cos}}^{4}x}\\ =\frac{2-{\mathrm{cos}}^{2}x}{{\mathrm{cos}}^{3}x}\\ \frac{{d}^{3}}{{\mathrm{dx}}^{3}}\frac{1}{\mathrm{cos}x}\\ =\frac{-2\mathrm{cos}x\left(-\mathrm{sin}x\right){\mathrm{cos}}^{3}x-\left(2-{\mathrm{cos}}^{2}x\right)3{\mathrm{cos}}^{2}x\left(-\mathrm{sin}x\right)}{{\mathrm{cos}}^{6}x}\\ =\frac{2{\mathrm{cos}}^{4}x\mathrm{sin}x+6{\mathrm{cos}}^{2}x\mathrm{sin}x-3{\mathrm{cos}}^{4}x\mathrm{sin}x}{{\mathrm{cos}}^{6}x}\\ =\frac{6{\mathrm{cos}}^{2}x\mathrm{sin}x-{\mathrm{cos}}^{4}x\mathrm{sin}x}{{\mathrm{cos}}^{6}x}\\ =\frac{6\mathrm{sin}x}{{\mathrm{cos}}^{4}x}-\frac{\mathrm{sin}x}{{\mathrm{cos}}^{2}x}\\ \frac{{d}^{4}}{{\mathrm{dx}}^{4}}\frac{1}{\mathrm{cos}x}\\ =6·\frac{{\mathrm{cos}}^{5}x-\left(\mathrm{sin}x\right)\left(4{\mathrm{cos}}^{3}x\right)\left(-\mathrm{sin}x\right)}{{\mathrm{cos}}^{8}x}-\frac{{\mathrm{cos}}^{3}x-\left(\mathrm{sin}x\right)\left(2\mathrm{cos}x\right)\left(-\mathrm{sin}x\right)}{{\mathrm{cos}}^{4}x}\\ \frac{1}{\mathrm{cos}x}=1+\frac{{x}^{2}}{2!}+\frac{1}{4!}·\left(6-1\right){x}^{4}+O\left({x}^{6}\right)\\ =1+\frac{1}{2}{x}^{2}+\frac{5}{24}{x}^{4}+O\left({x}^{6}\right)\end{array}$

コード

Python 3

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

print('11.')

x = symbols('x')
f = sum([1 / factorial(n) * Derivative(1 / cos(x), x, n).subs({x: 0}) * x ** n
for n in range(5)])

for o in [f, f.doit()]:
pprint(o)
print()

p = plot(cos(x), 1 / cos(x), f.doit(),
(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('sample11.png')


C:\Users\...>py sample11.py
11.
⎛  4        ⎞│         ⎛  3        ⎞│         ⎛  2        ⎞│
4 ⎜ d ⎛  1   ⎞⎟│       3 ⎜ d ⎛  1   ⎞⎟│       2 ⎜ d ⎛  1   ⎞⎟│
x ⋅⎜───⎜──────⎟⎟│      x ⋅⎜───⎜──────⎟⎟│      x ⋅⎜───⎜──────⎟⎟│
⎜  4⎝cos(x)⎠⎟│         ⎜  3⎝cos(x)⎠⎟│         ⎜  2⎝cos(x)⎠⎟│
⎝dx         ⎠│x=0      ⎝dx         ⎠│x=0      ⎝dx         ⎠│x=0     ⎛d ⎛  1
──────────────────── + ──────────────────── + ──────────────────── + x⋅⎜──⎜───
24                     6                      2               ⎝dx⎝cos

⎞⎞│
───⎟⎟│    + 1
(x)⎠⎠│x=0

4    2
5⋅x    x
──── + ── + 1
24    2

C:\Users\...>