## 2019年12月4日水曜日

### 数学 - Python - 解析学 - “ε-δ”その他 - εとδ - 集積点 - 増加数列、減少数列、区間内の点の数列、極限、はさみうちの原理

1. $\begin{array}{l}{a}_{n}\le {c}_{n}\le {b}_{n}\\ \underset{n\to \infty }{\mathrm{lim}}{a}_{n}=\underset{n\to \infty }{\mathrm{lim}}{b}_{n}=c\end{array}$

よって、

$\underset{n\to \infty }{\mathrm{lim}}{c}_{n}=c$

コード

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

print('2.')

n = symbols('n', integer=True, positive=True)
an = -1 / n
bn = 2 / n
cn = (an + bn) / 2

class MyTestCase(TestCase):
def test_compare(self):
self.assertLessEqual(an, cn)
self.assertLessEqual(cn, bn)

def test_limit(self):
self.assertEqual(Limit(an, n, oo).doit(), Limit(bn, n, oo).doit())
self.assertEqual(Limit(bn, n, oo).doit(), Limit(cn, n, oo).doit())

p = plot(an,
bn,
cn,
(n, 1, 11),
ylim=(-5, 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('sample2.png')

if __name__ == '__main__':
main()


% ./sample2.py -v
2.
test_compare (__main__.MyTestCase) ... ok
test_limit (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.218s

OK
%