## 2020年3月3日火曜日

### 数学 - Python - 解析学 - 多変数の関数 - ベクトルの微分 - 微分係数 - 曲線、三角関数(正弦と余弦)、速度ベクトル、加速度ベクトル、長さ

1. $\begin{array}{l}X\text{'}\left(t\right)=\left(-a\left(\mathrm{sin}t\right),a\left(\mathrm{cos}t\right),b\right)\\ ∥X\text{'}\left(t\right)∥\\ =\sqrt{{a}^{2}{\mathrm{sin}}^{2}t+{a}^{2}{\mathrm{cos}}^{2}t+{b}^{2}}\\ =\sqrt{{a}^{2}+{b}^{2}}\\ X\text{'}\text{'}\left(t\right)=\left(-a\left(\mathrm{cos}t\right),-a\left(\mathrm{sin}t\right),0\right)\\ ∥X\text{'}\text{'}\left(t\right)∥\\ =\sqrt{{a}^{2}{\mathrm{cos}}^{2}t+{a}^{2}{\mathrm{sin}}^{2}t+0}\\ =\sqrt{{a}^{2}}\\ =\left|a\right|\end{array}$

よって、 速度ベクトル、加速度ベクトルは一定の長さをもつ。

（証明終）

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import symbols, Matrix, Derivative, sin, cos, sqrt
from sympy.plotting import plot3d_parametric_line

print('22.')

t, a, b = symbols('t, a, b', real=True)
x = Matrix([a * cos(t), a * sin(t), b * t])

class MyTestCase(TestCase):
def test1(self):
self.assertEqual(Derivative(x, t, 1).doit().norm().simplify(),
sqrt(a ** 2 + b ** 2))

def test2(self):
self.assertEqual(Derivative(x, t, 2).doit().norm().simplify(), abs(a))

p = plot3d_parametric_line(*x.subs({a: 1, b: -2}),
legend=True,
show=False)

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
o.line_color = color

p.show()
p.save('sample22.png')

if __name__ == "__main__":
main()


% ./sample22.py -v
22.
test1 (__main__.MyTestCase) ... ok
test2 (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.418s

OK
%