## 2019年5月8日水曜日

### 数学 - Python - 解析学 - 級数 - テイラーの公式 - 2項展開(累乗根、展開式の剰余項の評価)

1. $\begin{array}{l}\left|{R}_{2}\right|\\ =\frac{1}{2}·\left|\frac{1}{2}·\left(-\frac{1}{2}\right)\right|{\left(1+c\right)}^{\frac{1}{4}-1}{\left|0.01\right|}^{2}\\ \le \frac{1}{8}·1{0}^{-4}\end{array}$

2. $\begin{array}{l}\left|{R}_{2}\right|\\ \le \frac{1}{8}{\left|0.2\right|}^{2}\\ =\frac{1}{2}·1{0}^{-2}\end{array}$

3. $\begin{array}{l}\left|{R}_{2}\right|\\ \le \frac{1}{8}·{\left|0.1\right|}^{2}\\ =\frac{1}{8}·1{0}^{-2}\end{array}$

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, root, plot, Rational

print('5.')

x = symbols('x')
f = root(1 + x, 4)
g = 1 + x / 4
xs = [0.01, 0.2, 0.1]
rs = [Rational(1, 8) * 10 ** -4,
Rational(1, 2) * 10 ** -2,
Rational(1, 8) * 10 ** -2]

for i, (x0, r) in enumerate(zip(xs, rs)):
print(f'({chr(ord("a") + i)})')
print(abs((f - g).subs({x: x0})) <= r)

p = plot(f, g, (x, -0.2, 0.2),
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('sample5.png')


C:\Users\...>py sample5.py
5.
(a)
True
(b)
True
(c)
True

C:\Users\...>