## 2019年10月22日火曜日

### 数学 - Python - 解析学 - 級数 - べき級数の微分と積分 - 無限等比級数

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

コード

Python 3

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

print('4.')

x, n = symbols('x, n')
t = (-1) ** n * x ** (2 * n + 1) / (2 * n + 1)
f = summation(t, (n, 0, oo))
f1 = Derivative(f, x, 1).doit()

for o in [f, f1]:
pprint(o)
print()

def g(m):
return sum([t.subs({n: k}) for k in range(m + 1)])

fs = [1 / (1 + x ** 2)] + [g(m) for m in range(9)]
p = plot(*fs,
(x, -2, 2),
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(fs, colors):
pprint(o)
print()

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

% ./sample4.py
4.
⎛⎧    atan(x)                         ⎞
⎜⎪    ───────       for x ≥ -1 ∧ x ≤ 1⎟
⎜⎪       x                            ⎟
⎜⎪                                    ⎟
⎜⎪  ∞                                 ⎟
⎜⎪ ____                               ⎟
⎜⎪ ╲                                  ⎟
x⋅⎜⎨  ╲       n  2⋅n                    ⎟
⎜⎪   ╲  (-1) ⋅x                       ⎟
⎜⎪   ╱  ──────────      otherwise     ⎟
⎜⎪  ╱    2⋅n + 1                      ⎟
⎜⎪ ╱                                  ⎟
⎜⎪ ‾‾‾‾                               ⎟
⎜⎪n = 0                               ⎟
⎝⎩                                    ⎠

⎛⎧              1        atan(x)                               ⎞
⎜⎪          ────────── - ───────             for x ≥ -1 ∧ x ≤ 1⎟   ⎛⎧
⎜⎪            ⎛ 2    ⎞       2                                 ⎟   ⎜⎪
⎜⎪          x⋅⎝x  + 1⎠      x                                  ⎟   ⎜⎪
⎜⎪                                                             ⎟   ⎜⎪
⎜⎪⎧    1        atan(x)                                        ⎟   ⎜⎪⎧    at
⎜⎪⎪────────── - ───────  for x ≥ -1 ∧ x ≤ 1                    ⎟   ⎜⎪⎪    ──
⎜⎪⎪  ⎛ 2    ⎞       2                                          ⎟   ⎜⎪⎪
⎜⎪⎪x⋅⎝x  + 1⎠      x                                           ⎟   ⎜⎪⎪
⎜⎪⎪                                                            ⎟   ⎜⎪⎪  ∞
x⋅⎜⎨⎪  ∞                                                         ⎟ + ⎜⎨⎪ ____
⎜⎪⎪ ____                                                       ⎟   ⎜⎪⎪ ╲
⎜⎪⎨ ╲                                            otherwise     ⎟   ⎜⎪⎨  ╲
⎜⎪⎪  ╲         n    2⋅n                                        ⎟   ⎜⎪⎪   ╲
⎜⎪⎪   ╲  2⋅(-1) ⋅n⋅x                                           ⎟   ⎜⎪⎪   ╱
⎜⎪⎪   ╱  ──────────────      otherwise                         ⎟   ⎜⎪⎪  ╱
⎜⎪⎪  ╱    x⋅(2⋅n + 1)                                          ⎟   ⎜⎪⎪ ╱
⎜⎪⎪ ╱                                                          ⎟   ⎜⎪⎪ ‾‾‾‾
⎜⎪⎪ ‾‾‾‾                                                       ⎟   ⎜⎪⎪n = 0
⎜⎪⎩n = 0                                                       ⎟   ⎝⎩⎩
⎝⎩                                                             ⎠

atan(x)                                   ⎞
───────                 for x ≥ -1 ∧ x ≤ 1⎟
x                                      ⎟
⎟
an(x)                                             ⎟
─────       for x ≥ -1 ∧ x ≤ 1                    ⎟
x                                                ⎟
⎟
⎟
⎟
⎟
n  2⋅n                          otherwise     ⎟
(-1) ⋅x                                           ⎟
──────────      otherwise                         ⎟
2⋅n + 1                                          ⎟
⎟
⎟
⎟
⎠

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

(x, green)

⎛   3          ⎞
⎜  x           ⎟
⎜- ── + x, blue⎟
⎝  3           ⎠

⎛ 5    3           ⎞
⎜x    x            ⎟
⎜── - ── + x, brown⎟
⎝5    3            ⎠

⎛   7    5    3            ⎞
⎜  x    x    x             ⎟
⎜- ── + ── - ── + x, orange⎟
⎝  7    5    3             ⎠

⎛ 9    7    5    3            ⎞
⎜x    x    x    x             ⎟
⎜── - ── + ── - ── + x, purple⎟
⎝9    7    5    3             ⎠

⎛   11    9    7    5    3          ⎞
⎜  x     x    x    x    x           ⎟
⎜- ─── + ── - ── + ── - ── + x, pink⎟
⎝   11   9    7    5    3           ⎠

⎛ 13    11    9    7    5    3          ⎞
⎜x     x     x    x    x    x           ⎟
⎜─── - ─── + ── - ── + ── - ── + x, gray⎟
⎝ 13    11   9    7    5    3           ⎠

⎛   15    13    11    9    7    5    3             ⎞
⎜  x     x     x     x    x    x    x              ⎟
⎜- ─── + ─── - ─── + ── - ── + ── - ── + x, skyblue⎟
⎝   15    13    11   9    7    5    3              ⎠

⎛ 17    15    13    11    9    7    5    3            ⎞
⎜x     x     x     x     x    x    x    x             ⎟
⎜─── - ─── + ─── - ─── + ── - ── + ── - ── + x, yellow⎟
⎝ 17    15    13    11   9    7    5    3             ⎠

\$