## 2019年9月12日木曜日

### 数学 - Python - 解析学 - 級数 - 絶対収束と交代級数の収束 - 累乗(べき乗、平方)、収束と絶対収束、極限

1. $\begin{array}{l}\sum \left|{\left(-1\right)}^{n}\frac{{n}^{2}}{{n}^{2}+1}\right|\\ =\sum \frac{{n}^{2}}{{n}^{2}+1}\end{array}$

よって絶対収束しない。

また、 収をもしない。

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, summation, oo, plot, root
import matplotlib.pyplot as plt

print('14.')

n = symbols('n')
f = (-1) ** n * n ** 2 / (n ** 2 + 1)
s1 = summation(f, (n, 1, oo))
s2 = summation(abs(f), (n, 1, oo))
for o in [s1, s2]:
pprint(o)
print()

def g(m):
return sum([f.subs({n: n0}) for n0 in range(1, m)])

def h(m):
return sum([abs(f.subs({n: n0})) for n0 in range(1, m)])

p = plot(f, abs(f),
(n, 1, 11),
legend=True,
show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

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

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

ms = range(1, 11)
plt.plot(ms, [g(m) for m in ms],
ms, [h(m) for m in ms],
ms, [f.subs({n: m}) for m in ms])
plt.legend(['Σ (-1)^n n^2 / (n^2 + 1)',
'Σ |(-1)^n n^2 / (n^2 + 1)|',
'(-1)^n n^2 / (n^2 + 1)',
'|(-1)^n n^2 / (n^2 + 1)|'])
plt.savefig('sample14.png')


C:\Users\...>py sample14.py
14.
∞
_____
╲
╲        n  2
╲   (-1) ⋅n
╲  ────────
╱    2
╱    n  + 1
╱
╱
‾‾‾‾‾
n = 1

∞
_____
╲
╲              │   2  │
╲    -π⋅im(n) │  n   │
╲  ℯ        ⋅│──────│
╱            │ 2    │
╱             │n  + 1│
╱
╱
‾‾‾‾‾
n = 1

c:\Users\...>