## 2020年2月18日火曜日

### 数学 - Python - 解析学 - 関数列と関数級数 - 整級数 - 対数関数、収束半径

1. $\begin{array}{l}\left|x\right|<1\\ \mathrm{log}\left(1+x\right)=\sum _{n=1}^{\infty }{\left(-1\right)}^{n-1}\frac{{x}^{n}}{n}\\ \mathrm{log}\left(1-x\right)\\ =\mathrm{log}\left(1+\left(-x\right)\right)\\ =\sum _{n=1}^{\infty }{\left(-1\right)}^{n-1}\frac{{\left(-x\right)}^{n}}{n}\\ =\sum _{n=1}^{\infty }{\left(-1\right)}^{2n-1}\frac{{x}^{n}}{n}\\ =-\sum _{n=1}^{\infty }\frac{{x}^{n}}{n}\\ \frac{1}{2}\mathrm{log}\frac{1+x}{1-x}\\ =\frac{1}{2}\left(\mathrm{log}\left(1+x\right)-\mathrm{log}\left(1-x\right)\right)\\ =\frac{1}{2}\left(\sum _{n=1}^{\infty }{\left(-1\right)}^{n-1}\frac{{x}^{n}}{n}+\sum _{n=1}^{\infty }\frac{{x}^{n}}{n}\right)\\ =\frac{1}{2}\sum _{n=1}^{\infty }\left({\left(-1\right)}^{n-1}+1\right)\frac{{x}^{n}}{n}\\ =\frac{1}{2}\sum _{n=1}^{\infty }2·\frac{{x}^{2n-1}}{2n-1}\\ =\sum _{n=1}^{\infty }\frac{{x}^{2n-1}}{2n-1}\\ =\sum _{n=0}^{\infty }\frac{{x}^{2n+1}}{2n+1}\end{array}$

コード

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

print('4.')

x = symbols('x')
n = symbols('n', integer=True)
f = log((1 + x) / (1 - x)) / 2
g = x ** (2 * n + 1) / (2 * n + 1)
gs = [sum([g.subs({n: k}) for k in range(n0)])
for n0 in range(9)]

p = plot(f, *gs,
(x, -0.9, 3),
ylim=(-2, 2),
legend=False,
show=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([f] + gs, colors):
pprint(o)

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


% ./sample4.py
4.
⎛   ⎛x + 1⎞     ⎞
⎜log⎜─────⎟     ⎟
⎜   ⎝1 - x⎠     ⎟
⎜──────────, red⎟
⎝    2          ⎠
(0, green)
(x, blue)
⎛ 3           ⎞
⎜x            ⎟
⎜── + x, brown⎟
⎝3            ⎠
⎛ 5    3            ⎞
⎜x    x             ⎟
⎜── + ── + x, orange⎟
⎝5    3             ⎠
⎛ 7    5    3            ⎞
⎜x    x    x             ⎟
⎜── + ── + ── + x, purple⎟
⎝7    5    3             ⎠
⎛ 9    7    5    3          ⎞
⎜x    x    x    x           ⎟
⎜── + ── + ── + ── + x, pink⎟
⎝9    7    5    3           ⎠
⎛ 11    9    7    5    3          ⎞
⎜x     x    x    x    x           ⎟
⎜─── + ── + ── + ── + ── + x, gray⎟
⎝ 11   9    7    5    3           ⎠
⎛ 13    11    9    7    5    3             ⎞
⎜x     x     x    x    x    x              ⎟
⎜─── + ─── + ── + ── + ── + ── + x, skyblue⎟
⎝ 13    11   9    7    5    3              ⎠
⎛ 15    13    11    9    7    5    3            ⎞
⎜x     x     x     x    x    x    x             ⎟
⎜─── + ─── + ─── + ── + ── + ── + ── + x, yellow⎟
⎝ 15    13    11   9    7    5    3             ⎠
%