## 2020年5月6日水曜日

### 数学 - Python - 解析学 - 多変数の関数 - 合成微分律と勾配ベクトル - 接平面 - 曲面、垂直なベクトル、点とその接平面、法線の方程式、内積

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

よって求める接平面の方程式は

$\begin{array}{l}2\left(6,2,3\right)·\left(x,y,z\right)=2\left(6,2,3\right)·\left(6,2,3\right)\\ 6x+2y+3z=36+4+9\\ 6x+2y+3z=49\end{array}$

法線の方程式は、

$\begin{array}{l}\left(x,y,z\right)=\left(6,2,3\right)+t\left(6,2,3\right)\\ \left(x,y,z\right)=t\left(6,2,3\right)\end{array}$

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

接平面の方程式。

$x+y+2z=2$

法線の方程式。

$X=\left(1,1,0\right)+t\left(1,1,2\right)$

3. $\begin{array}{l}grad\left({x}^{2}+x{y}^{2}+{y}^{3}+z+1\right)\\ =\left(2x+{y}^{2},2xy+3{y}^{2},1\right)\\ gradf\left(2,-3,4\right)\\ =\left(13,15,1\right)\\ 13x+15y+z=26-45+4=-15\\ X=\left(2,-3,4\right)+t\left(13,15,1\right)\end{array}$

4. $\begin{array}{l}grad\left(2y-{z}^{3}-3xz\right)\\ =\left(-3z,2,-3{z}^{2}-3x\right)\\ gradf\left(1,7,2\right)\\ =\left(-6,2,-12-3\right)\\ =\left(-6,2,-15\right)\\ -6x+2y-15z=-6+14-30=-22\\ X=\left(1,7,2\right)+t\left(-6,2,-15\right)\end{array}$

5. $\begin{array}{l}grad\left({x}^{2}{y}^{2}+xz-2{y}^{3}\right)\\ =\left(2x{y}^{2}+z,2{x}^{2}y-6{y}^{2},x\right)\\ gradf\left(2,1,4\right)\\ =\left(8,2,2\right)\\ =2\left(4,1,1\right)\\ 4x+y+z=8+1+4=13\\ X=\left(2,1,4\right)+t\left(4,1,1\right)\end{array}$

6. $\begin{array}{l}grad\left(\mathrm{sin}\left(xy\right)+\mathrm{sin}\left(yz\right)+\mathrm{sin}\left(xz\right)\right)\\ =\left(y\mathrm{cos}\left(xy\right)+z\mathrm{cos}\left(xz\right),x\mathrm{cos}\left(xy\right)+z\mathrm{cos}\left(yz\right),y\mathrm{cos}\left(yz\right)+x\mathrm{cos}\left(xz\right)\right)\\ gradf\left(1,\frac{\pi }{2},0\right)\\ =\left(0,0,\frac{\pi }{2}+1\right)\\ \left(\frac{\pi }{2}+1\right)z=0\\ z=0\\ X=\left(1,\frac{\pi }{2},0\right)+t\left(0,0,\frac{\pi }{2}+1\right)\end{array}$

コード

#!/usr/bin/env python3
from sympy import symbols, sin, solve
from sympy.plotting import plot3d

print('1.')

x, y, z, t = symbols('x, y, z, t', real=True)
eqs = [x ** 2 + y ** 2 + z ** 2 - 49,
x * y + y * z + z * x - 1,
x ** 2 + x * y ** 2 + y ** 3 + z + 1,
2 * y - z ** 3 - 3 * x * z,
x ** 2 * y ** 2 + x * z - 2 * y ** 3 - 10,
sin(x * y) + sin(y * z) + sin(x * z) - 1]
eqs1 = [6 * x + 2 * y + 3 * z - 49,
x + y + 2 * z - 2,
13 * x + 15 * y + z + 15,
-6 * x + 2 * y - 15 * z + 22,
4 * x + y + z - 13,
z]

for i, (eq, eq1) in enumerate(zip(eqs, eqs1)):
c = chr(ord("a") + i)
print(f'({c})')
try:
zs = solve(eq, z) + solve(eq1, z)
p = plot3d(*zs,
show=False)
p.save(f'sample1_{c}.png')
except Exception as err:
print(err)
p.show()


% ./sample1.py
1.
(a)
(b)
<string>:1: RuntimeWarning: divide by zero encountered in true_divide
float division by zero
(c)
(d)
(e)
(f)
multiple generators [tan(x*z/2), tan(y*z/2)]
No algorithms are implemented to solve equation -1 + 2*tan(y*z/2)/(tan(y*z/2)**2 + 1) + 2*tan(x*z/2)/(tan(x*z/2)**2 + 1) + 2*tan(x*y/2)/(tan(x*y/2)**2 + 1)
%