## 2019年3月17日日曜日

### 数学 - Python - 解析学 - 級数 - テイラーの公式 - 三角関数(正接、剰余項の評価)

1. $\begin{array}{}0\le x\le 0.2<\frac{\pi }{2}\\ \frac{{d}^{4}}{{\mathrm{dx}}^{4}}\mathrm{tan}x\\ =\frac{{d}^{4}}{{\mathrm{dx}}^{4}}\frac{\mathrm{sin}x}{\mathrm{cos}x}\\ =\frac{{d}^{3}}{{\mathrm{dx}}^{3}}\frac{1}{{\mathrm{cos}}^{2}x}\\ =\frac{{d}^{2}}{{\mathrm{dx}}^{2}}\frac{-2\mathrm{cos}x\left(-\mathrm{sin}x\right)}{{\mathrm{cos}}^{4}x}\\ =\frac{{d}^{2}}{{\mathrm{dx}}^{2}}\frac{2\mathrm{cos}x\mathrm{sin}x}{{\mathrm{cos}}^{4}x}\\ =2\frac{{d}^{2}}{{\mathrm{dx}}^{2}}\frac{\mathrm{sin}x}{{\mathrm{cos}}^{3}x}\\ =2\frac{d}{\mathrm{dx}}\frac{{\mathrm{cos}}^{4}x-\mathrm{sin}x\left(3{\mathrm{cos}}^{2}x\right)\left(-\mathrm{sin}x\right)}{{\mathrm{cos}}^{6}x}\\ =2\frac{d}{\mathrm{dx}}\frac{{\mathrm{cos}}^{4}x+3{\mathrm{sin}}^{2}x{\mathrm{cos}}^{2}x}{{\mathrm{cos}}^{6}x}\\ =2\frac{d}{\mathrm{dx}}\frac{{\mathrm{cos}}^{2}x+3{\mathrm{sin}}^{2}x}{{\mathrm{cos}}^{4}x}\\ =2\frac{d}{\mathrm{dx}}\left(\frac{1}{{\mathrm{cos}}^{2}x}+\frac{2{\mathrm{sin}}^{2}x}{{\mathrm{cos}}^{4}x}\right)\\ =2\left(\frac{-2\mathrm{cos}x\left(-\mathrm{sin}x\right)}{{\mathrm{cos}}^{4}x}+2·\frac{2\mathrm{sin}x{\mathrm{cos}}^{5}x-{\mathrm{sin}}^{2}x\left(4{\mathrm{cos}}^{3}x\right)\left(-\mathrm{sin}x\right)}{{\mathrm{cos}}^{8}x}\right)\\ =4\left(\frac{\mathrm{sin}x}{{\mathrm{cos}}^{3}x}+\frac{2\mathrm{sin}x{\mathrm{cos}}^{5}x+4{\mathrm{sin}}^{3}x{\mathrm{cos}}^{3}x}{{\mathrm{cos}}^{8}x}\right)\\ =4\left(\frac{\mathrm{sin}x}{{\mathrm{cos}}^{3}x}+\frac{2\mathrm{sin}x}{{\mathrm{cos}}^{3}x}+\frac{4{\mathrm{sin}}^{3}x}{{\mathrm{cos}}^{5}x}\right)\\ <4\left(1+2+4\right)\\ =28\end{array}$

剰余項を評価。

$\begin{array}{}\left|{R}_{4}\right|\\ \le 28·\frac{{\left(0.2\right)}^{4}}{4!}\\ =\frac{28·{2}^{4}·1{0}^{-4}}{4!}\\ =28·4·1{0}^{-4}\end{array}$

コード

Python 3

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

print('7.')

x = symbols('x')
f = tan(x)
g = sum([Derivative(f, x, i).doit().subs({x: 0}) * x ** i / factorial(i)
for i in range(5)])
r = f - g
for o in [g, g.doit()]:
pprint(o)
print()

p = plot(r, 2 * 4 * 10 ** -4, (x, -0.5, 0.5), show=False, legend=True)
colors = ['red', 'green', 'blue']
for o, color in zip(p, colors):
o.line_color = color

p.show()
p.save('sample7.png')


C:\Users\...>py -3 sample7.py
7.
3
x
── + x
3

3
x
── + x
3

C:\Users\...>