## 2020年7月19日日曜日

### 数学 - Python - 解析学 - ベクトルの微分 - 微分係数 - 位置ベクトルと速度ベクトル、関係、直交

1. $\frac{d}{\mathrm{dt}}\left(\mathrm{cos}t,\mathrm{sin}t\right)=\left(-\mathrm{sin}t,\mathrm{cos}t\right)$
$\left(\mathrm{cos}t,\mathrm{sin}t\right)·\left(-\mathrm{sin}t,\mathrm{cos}t\right)$
$=-\mathrm{sin}t\mathrm{cos}t+\mathrm{sin}t\mathrm{cos}t$
$=0$

よって、位値ベクトルと 速度ベクトルは直交する。

2. $\frac{·d}{\mathrm{dt}}\left(\mathrm{cos}3t,\mathrm{sin}3t\right)=\left(-3\mathrm{sin}3t,3\mathrm{cos}3t\right)$
$\left(\mathrm{cos}3t,\mathrm{sin}3t\right)·\left(-3\mathrm{sin}3t,3\mathrm{cos}3t\right)$
$=3\left(-\mathrm{cos}3t\mathrm{sin}3t+\mathrm{sin}3t\mathrm{cos}3t\right)$
$=0$

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import Matrix, sin, cos, exp, log, Derivative
from sympy.abc import t
from sympy.plotting import plot_parametric

print('5.')

class Test(TestCase):
def test3(self):
a = Matrix([cos(t), sin(t)])
self.assertEqual(
a.dot(Derivative(a, t, 1).doit()), 0
)

def test4(self):
a = Matrix([cos(3 * t), sin(3 * t)])
self.assertEqual(
a.dot(Derivative(a, t, 1).doit()), 0
)

p = plot_parametric(
(cos(t), sin(t), (t, -5, 5)),
*[(cos(t0) + t * (-sin(t0)),
sin(t0) + t * cos(t0),
(t, 0, 1))
for t0 in range(-5, 6)],
legend=False,
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.save('sample5.png')
p.show()

if __name__ == "__main__":
main()


% ./sample5.py -v
5.
test3 (__main__.Test) ... ok
test4 (__main__.Test) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.007s

OK
%