2020年4月14日火曜日

数学 - Python - 解析学 - 多変数の関数 - 多変数の関数 - 2変数、極限、極限の極限、順序

• $\begin{array}{l}\underset{h\to 0}{\mathrm{lim}}g\left(h,k\right)\\ =\underset{h\to 0}{\mathrm{lim}}\frac{{h}^{2}-{k}^{2}}{{h}^{2}+{k}^{2}}\\ =-1\end{array}$

• $\begin{array}{l}\underset{k\to 0}{\mathrm{lim}}\left(\underset{h\to 0}{\mathrm{lim}}g\left(h,k\right)\right)\\ =\underset{k\to 0}{\mathrm{lim}}\left(-1\right)\\ =-1\end{array}$

• $\begin{array}{l}\underset{k\to 0}{\mathrm{lim}}g\left(h,k\right)\\ =\underset{k\to 0}{\mathrm{lim}}\frac{{h}^{2}-{k}^{2}}{{h}^{2}+{k}^{2}}\\ =1\end{array}$

• $\begin{array}{l}\underset{h\to 0}{\mathrm{lim}}\left(\underset{k\to 0}{\mathrm{lim}}g\left(h,k\right)\right)\\ =\underset{h\to 0}{\mathrm{lim}}1\\ =1\end{array}$

コード

#!/usr/bin/env python3
import random
from unittest import TestCase, main
from sympy import symbols
from sympy.plotting import plot3d

print('7.')

h, k = symbols('h, k')
f = (h ** 2 - k ** 2) / (h ** 2 + k ** 2)

class TestInequalities(TestCase):
def test_h(self):
self.assertEqual(f.limit(h, 0), -1)

def test_hk(self):
self.assertEqual(f.limit(h, 0).limit(k, 0), -1)

def test_k(self):
self.assertEqual(f.limit(k, 0), 1)

def test_kh(self):
self.assertEqual(f.limit(k, 0).limit(h, 0), 1)

p = plot3d(f, show=True)
p.save('sample7.png')

if __name__ == "__main__":
main()


% ./sample7.py -v
7.
test_h (__main__.TestInequalities) ... ok
test_hk (__main__.TestInequalities) ... ok
test_k (__main__.TestInequalities) ... ok
test_kh (__main__.TestInequalities) ... ok

----------------------------------------------------------------------
Ran 4 tests in 0.430s

OK
%