## 2019年9月2日月曜日

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

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

よって問題の無限級数は絶対収束する。

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, summation, oo, Integral, plot, sin, cos, pi
from sympy import Rational
import matplotlib.pyplot as plt

print('4.')

n = symbols('n')
f = abs((-1) ** n / (n ** 2 + 1))
s = summation(f, (n, 1, oo))
I = Integral(f, (n, 1, oo))

for o in [s, I, I.doit()]:
pprint(o)
print()

p = plot(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('sample4.png')

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

ms = range(1, 11)
plt.plot(ms, [g(m) for m in ms])
plt.legend(['Σ |(sin πn + cos 2πn) / n^(3/2)|',
'|(sin πn + cos 2πn) / n^(3/2)|',
'1 / n^(3/2)'])
plt.savefig('sample4.png')


C:\Users\...>py sample4.py
4.
∞
____
╲
╲    -π⋅im(n) │  1   │
╲  ℯ        ⋅│──────│
╱            │ 2    │
╱             │n  + 1│
╱
‾‾‾‾
n = 1

∞
⌠
⎮  -π⋅im(n) │  1   │
⎮ ℯ        ⋅│──────│ dn
⎮           │ 2    │
⎮           │n  + 1│
⌡
1

π
─
4

c:\Users\...>