## 2019年6月15日土曜日

### 数学 - Python - 解析学 - 級数 - テイラーの公式 - 対数関数、テイラー多項式、剰余項の評価

1. $\begin{array}{l}\frac{d}{\mathrm{dx}}\mathrm{log}\frac{1+x}{1-x}\\ =\frac{1-x}{1+x}·\frac{\left(1-x\right)+\left(1+x\right)}{{\left(1-x\right)}^{2}}\\ =\frac{2}{\left(1+x\right)\left(1-x\right)}\\ =\frac{2}{1-{x}^{2}}\\ \frac{{d}^{2}}{{\mathrm{dx}}^{2}}\mathrm{log}\frac{1+x}{1-x}\\ =\frac{-2\left(-2x\right)}{{\left(1-{x}^{2}\right)}^{2}}\\ =\frac{4x}{{\left(1-{x}^{2}\right)}^{2}}\\ \frac{{d}^{3}}{{\mathrm{dx}}^{3}}\mathrm{log}\frac{1+x}{1-x}\\ =\frac{4{\left(1-{x}^{2}\right)}^{2}-4x·2\left(1-{x}^{2}\right)\left(-2x\right)}{{\left(1-{x}^{2}\right)}^{4}}\\ =\frac{4\left(1-{x}^{2}\right)+16{x}^{2}}{{\left(1-{x}^{2}\right)}^{3}}\\ =\frac{4+12{x}^{2}}{{\left(1-{x}^{2}\right)}^{3}}\\ \frac{{d}^{4}}{d{x}^{4}}\mathrm{log}\frac{1+x}{1-x}\\ =\frac{24x{\left(1-{x}^{2}\right)}^{3}-\left(4+12{x}^{2}\right)·3{\left(1-{x}^{2}\right)}^{2}\left(-2x\right)}{{\left(1-{x}^{2}\right)}^{6}}\\ =\frac{24x\left(1-{x}^{2}\right)+\left(4+12{x}^{2}\right)6x}{{\left(1-{x}^{2}\right)}^{4}}\\ =\frac{24x-24{x}^{3}+24x+72{x}^{3}}{{\left(1-{x}^{2}\right)}^{4}}\\ =\frac{48{x}^{3}+48x}{{\left(1-{x}^{2}\right)}^{4}}\\ \frac{{d}^{5}}{d{x}^{5}}\mathrm{log}\frac{1+x}{1-x}\\ =\frac{48\left(\left(3{x}^{2}+1\right){\left(1-{x}^{2}\right)}^{4}-\left({x}^{3}+x\right)4{\left(1-{x}^{2}\right)}^{3}\left(-2x\right)\right)}{{\left(1-{x}^{2}\right)}^{8}}\\ =\frac{48\left(\left(3{x}^{2}+1\right)\left(1-{x}^{2}\right)+8x\left({x}^{3}+x\right)\right)}{{\left(1-{x}^{2}\right)}^{5}}\\ =\frac{48\left(3{x}^{2}-3{x}^{4}+1-{x}^{2}+8{x}^{4}+8{x}^{2}\right)}{{\left(1-{x}^{2}\right)}^{5}}\\ =\frac{48\left(5{x}^{4}+10{x}^{2}+1\right)}{{\left(1-{x}^{2}\right)}^{5}}\end{array}$

よって、求める問題の対数関数に対する3次のテイラー多項式は、

$\begin{array}{l}2x+\frac{4}{3!}{x}^{3}\\ =2x+\frac{2}{3}{x}^{3}\end{array}$

剰余項の評価は、

$\left|{R}_{5}\right|\le \frac{48}{5!}=\frac{2}{5}$

コード

Python 3

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

print('18.')

x = symbols('x', real=True)
f = log((1 + x) / (1 - x))
g = sum([Derivative(f, x, n).doit().subs({x: 0}) / factorial(n) * x ** n
for n in range(4)])
h = Derivative(f, x, 5).doit().factor()

for o in [g, h]:
pprint(o)
print()

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

C:\Users\...>py sample18.py
18.
3
2⋅x
──── + 2⋅x
3

⎛   4       2    ⎞
-48⋅⎝5⋅x  + 10⋅x  + 1⎠
───────────────────────
5        5
(x - 1) ⋅(x + 1)

C:\Users\...>