## 2020年8月4日火曜日

### 数学 - Python - 解析学 - ベクトルの微分 - 微分係数 - 曲線、三角関数(正弦と余弦)、接線、z軸となす角、内積、ノルム

1. $X\text{'}\left(t\right)=\left(-a\left(\mathrm{sin}t\right),a\left(\mathrm{cos}t\right),b\right)$
$\mathrm{cos}\theta \left(t\right)$
$=\frac{X\text{'}\left(t\right)·\left(0,0,1\right)}{\parallel X\text{'}\left(t\right)\parallel \parallel \left(0,0,1\right)\parallel }$
$=\frac{b}{\sqrt{{a}^{2}{\mathrm{sin}}^{2}t+{a}^{2}{\mathrm{cos}}^{2}t+{b}^{2}}}$
$=\frac{b}{\sqrt{{a}^{2}+{b}^{2}}}$

（証明終）

コード

#!/usr/bin/env python3
from sympy import cos, sin, Matrix, Derivative
from sympy.plotting import plot3d_parametric_line, plot3d
from sympy.abc import t

print('21.')

a = 2
b = 3
x = Matrix([a * cos(t), a * sin(t), b * t])
x1 = Derivative(x, t, 1).doit()
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

p = plot3d_parametric_line(*x, legend=False, show=False)
for t0 in range(-5, 6):
p.append(
plot3d_parametric_line(
*(x.subs({t: t0}) + t * x1.subs({t: t0})),
(t, 0, 1),
legend=False,
show=False
)[0]
)
p.xlabel = 'x'
p.ylabel = 'y'
for o, color in zip(p, colors):
o.line_color = color
p.save(f'sample21.png')
p.show()


% ./sample21.py
21.
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy/ma/core.py:2831: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
_data = np.array(data, dtype=dtype, copy=copy,
%