## 2020年7月20日月曜日

### 数学 - Python - 解析学 - ベクトルの微分 - 微分係数 - 円、位置ベクトルと加速度ベクトル、向き

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

よって、 加速度ベクトルは位置ベクトルと反対の向きをもつ。

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

コード

#!/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('6.')

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

def test4(self):
a = Matrix([cos(3 * t), sin(3 * t)])
self.assertEqual(Derivative(a, t, 2).doit(), -9 * a)

p = plot_parametric(
(cos(t), sin(t), (t, -5, 5)),
*[(cos(t0) + t * (-cos(t0)),
sin(t0) + t * (-sin(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('sample6.png')
p.show()

if __name__ == "__main__":
main()


% ./sample6.py -v
6.
test3 (__main__.Test) ... ok
test4 (__main__.Test) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.011s

OK
%