## 2019年10月19日土曜日

### 数学 - Python - 解析学 - 関数の近似、テイラーの定理 - テイラーの定理 - 区間、無限回微分、絶対値、剰余項、収束、零

1. $\begin{array}{l}\left|{R}_{n}\right|\\ =\left|\frac{{f}^{\left(n\right)}\left(a\right)}{n!}{\left(x-a\right)}^{n}\right|\\ =\frac{\left|{f}^{\left(n\right)}\left(a\right)\right|}{n!}{\left|x-a\right|}^{n}\\ \le \frac{M}{n!}{\left|x-a\right|}^{n}\end{array}$

が成り立ち、

$\underset{n\to \infty }{\mathrm{lim}}\frac{M}{n!}{\left|x-a\right|}^{n}=0$

よって、 剰余項について、

$\underset{n\to \infty }{\mathrm{lim}}{R}_{n}=0$

コード

Python 3

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

print('1.')

x = symbols('x')
f = exp(x)
a = 0

def g(n):
return sum([Derivative(f, x, k).doit().subs({x: a}) / factorial(k) * (x - a) ** k for k in range(n + 1)])

fs = [f] + [g(n0) for n0 in range(10)]

p = plot(*fs,
(x, -5, 5),
ylim=(-5, 5),
show=False,
legend=False)

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
o.line_color = color

for o in zip(fs, colors):
pprint(o)
print()

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


% ./sample1.py
1.
⎛ x     ⎞
⎝ℯ , red⎠

(1, green)

(x + 1, blue)

⎛ 2               ⎞
⎜x                ⎟
⎜── + x + 1, brown⎟
⎝2                ⎠

⎛ 3    2                ⎞
⎜x    x                 ⎟
⎜── + ── + x + 1, orange⎟
⎝6    2                 ⎠

⎛ 4    3    2                ⎞
⎜x    x    x                 ⎟
⎜── + ── + ── + x + 1, purple⎟
⎝24   6    2                 ⎠

⎛  5    4    3    2              ⎞
⎜ x    x    x    x               ⎟
⎜─── + ── + ── + ── + x + 1, pink⎟
⎝120   24   6    2               ⎠

⎛  6     5    4    3    2              ⎞
⎜ x     x    x    x    x               ⎟
⎜─── + ─── + ── + ── + ── + x + 1, gray⎟
⎝720   120   24   6    2               ⎠

⎛  7      6     5    4    3    2                 ⎞
⎜ x      x     x    x    x    x                  ⎟
⎜──── + ─── + ─── + ── + ── + ── + x + 1, skyblue⎟
⎝5040   720   120   24   6    2                  ⎠

⎛   8      7      6     5    4    3    2                ⎞
⎜  x      x      x     x    x    x    x                 ⎟
⎜───── + ──── + ─── + ─── + ── + ── + ── + x + 1, yellow⎟
⎝40320   5040   720   120   24   6    2                 ⎠

%