## 2020年4月15日水曜日

### 数学 - Python - 解析学 - 多変数の関数 - 多変数の関数 - 偏微分係数、微分可能性、滑らかさ、連続性

1. $\begin{array}{l}\frac{\partial f}{\partial x}\\ =\frac{\partial }{\partial x}\frac{xy}{{x}^{2}+{y}^{2}}\\ =\frac{y\left({x}^{2}+{y}^{2}\right)-xy·2x}{{\left({x}^{2}+{y}^{2}\right)}^{2}}\\ =\frac{y\left({x}^{2}+{y}^{2}-2{x}^{2}\right)}{{\left({x}^{2}+{y}^{2}\right)}^{2}}\\ =\frac{y\left({y}^{2}-{x}^{2}\right)}{{\left({x}^{2}+{y}^{2}\right)}^{2}}\\ \frac{\partial f}{\partial y}=\frac{x\left({x}^{2}-{y}^{2}\right)}{{\left({x}^{2}+{y}^{2}\right)}^{2}}\end{array}$

コード

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

print('8.')

x, y = symbols('x, y')
f = x * y / (x ** 2 + y ** 2)

class TestInequalities(TestCase):
def test_dx(self):
self.assertEqual(
Derivative(f, x, 1).doit().simplify(),
y * (y ** 2 - x ** 2) / (x ** 2 + y ** 2) ** 2
)

def test_dy(self):
self.assertEqual(
Derivative(f, y, 1).doit().simplify(),
x * (x ** 2 - y ** 2) / (x ** 2 + y ** 2) ** 2
)

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

if __name__ == "__main__":
main()


% ./sample8.py -v
8.
test_dx (__main__.TestInequalities) ... ok
test_dy (__main__.TestInequalities) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.313s

OK
%