## 2020年4月1日水曜日

### 数学 - Python - 解析学 - 多変数の関数 - 多変数の関数 - 偏微分 - 勾配ベクトル(gradient)

1. $\begin{array}{l}grad\left(xy+z\right)\\ =\left(y,x,1\right)\\ gradf\left(1,2,3\right)\\ =\left(2,1,1\right)\end{array}$

2. $\begin{array}{l}grad\left({x}^{2}{y}^{5}+1\right)\\ =\left(2x{y}^{5},5{x}^{2}{y}^{4},0\right)\\ gradf\left(1,2,3\right)\\ =\left(64,80,0\right)\end{array}$

3. $\begin{array}{l}grad{e}^{xyz}\\ =\left({e}^{xyz}yz,{e}^{xyz}xz,{e}^{xyz}xy\right)\\ gradf\left(1,2,3\right)\\ =\left(6{e}^{6},3{e}^{6},2{e}^{6}\right)\end{array}$

4. $\begin{array}{l}grad\left(xyz\right)\\ =\left(yz,xz,xy\right)\\ gradf\left(1,2,3\right)\\ =\left(6,3,2\right)\end{array}$

5. $\begin{array}{l}grad\left(xz+yz+xy\right)\\ =\left(z+y,z+x,x+y\right)\\ gradf\left(1,2,3\right)\\ =\left(5,4,3\right)\end{array}$

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import symbols, Matrix, exp

print('11.')

x, y, z = symbols('x, y, z', real=True)
xyzs = [(y, x, 1),
(2 * x * y ** 5, 5 * x ** 2 * y ** 4, 0),
(exp(x * y * z) * y * z,
exp(x * y * z) * x * z,
exp(x * y * z) * x * y),
(y * z, x * z, x * y),
(z + y, z + x, x + y)]
p = {x: 1, y: 2, z: 3}
(64, 80, 0),
(6 * exp(6), 3 * exp(6), 2 * exp(6)),
(6, 3, 2),
(5, 4, 3)]

class TestPartialDerivative(TestCase):
def test(self):

if __name__ == "__main__":
main()


% ./sample11.py -v
11.
test (__main__.TestPartialDerivative) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.010s

OK
%