## 2019年8月19日月曜日

### 数学 - Python - 解析学 - 級数 - 積分による判定法 - 累乗(べき乗、平方)、指数関数、階乗、極限、ネイピア数(オイラー数)、収束

1. $\begin{array}{l}\frac{{a}_{n+1}}{{a}_{n}}\\ =\frac{\left(n+1\right)!}{{\left(n+1\right)}^{\left(n+1\right)}}·\frac{{n}^{n}}{n!}\\ =\frac{\left(n+1\right){n}^{n}}{{\left(n+1\right)}^{\left(n+1\right)}}\\ =\frac{{n}^{n}}{{\left(n+1\right)}^{n}}\\ =\frac{1}{{\left(1+\frac{1}{n}\right)}^{n}}\\ n\to \infty ⇒\frac{{a}_{n+1}}{{a}_{n}}=\frac{1}{e}\end{array}$

よって、

$\frac{{a}_{n+1}}{{a}_{n}}<\frac{1}{e}<1$

よって 、問題の級数は収束する。

コード

Python 3

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

print('6.')

n = symbols('n', integer=True)
f = factorial(n) / n ** n
s = summation(f, (n, 1, oo))
pprint(s)

I = Integral(f, (n, 1, oo))
ratio = f.subs({n: n + 1}) / f
l = Limit(ratio, n, oo, dir='-+')
for o in [I, I.doit(), l, l.doit()]:
pprint(o)
print()

p = plot(f, ratio, 1 / exp(1),
(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('sample6.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(['Σ n! / n^n'])
plt.savefig('sample6.png')


C:\Users\...>py sample6.py
6.
∞
___
╲
╲    -n
╱   n  ⋅n!
╱
‾‾‾
n = 1
∞
⌠
⎮  -n
⎮ n  ⋅n! dn
⌡
1

∞
⌠
⎮  -n
⎮ n  ⋅n! dn
⌡
1

⎛ n        -n - 1         ⎞
⎜n ⋅(n + 1)      ⋅(n + 1)!⎟
lim ⎜─────────────────────────⎟
n─→∞⎝            n!           ⎠

-1
ℯ

c:\Users\...>