2019年11月30日土曜日

数学 - Python - 解析学 - “ε-δ”その他 - εとδ - 極限 - 平方根、累乗、分母、無限大、零

1. $\underset{n\to \infty }{\mathrm{lim}}\frac{1}{\sqrt{n}}=0$

2. $\underset{n\to \infty }{\mathrm{lim}}\frac{3}{{n}^{2}}=0$

3. $\underset{n\to \infty }{\mathrm{lim}}\frac{5}{{n}^{\frac{1}{4}}}=0$

4. $\underset{n\to \infty }{\mathrm{lim}}\frac{1}{\sqrt{n}+1}=0$

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import pprint, symbols, plot, Limit, oo, Limit, sqrt, Rational

print('7.')
n = symbols('n', integer=True)
fs = [1 / sqrt(n), 3 / n ** 2, 5 / n ** Rational(1, 4), 1 / (sqrt(n) + 1)]

class MyTestCase(TestCase):
def test(self):
for f in fs:
self.assertEqual(Limit(f, n, oo).doit(), 0)

p = plot(*fs,
(n, 1, 11),
ylim=(0, 5),
show=False,
legend=True)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

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

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

if __name__ == '__main__':
main()


% ./sample7.py -v
7.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.357s

OK
%