## 2020年2月15日土曜日

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

1. $\begin{array}{l}v\left(t\right)\\ =\left(-\mathrm{sin}t,\mathrm{cos}t\right)\\ v\text{'}\left(t\right)\\ =\left(-\mathrm{cos}t,-\mathrm{sin}t\right)\\ =-\left(\mathrm{cos}t,\mathrm{sin}t\right)\end{array}$

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

2. $\begin{array}{l}v\left(t\right)\\ =\left(-3\mathrm{sin}3t,3\mathrm{cos}3t\right)\\ v\text{'}\left(t\right)\\ =\left(-9\mathrm{cos}3t,-9\mathrm{sin}3t\right)\\ =9\left(-\left(\mathrm{cos}3t,\mathrm{sin}3t\right)\right)\end{array}$

コード

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

print('6.')

t = symbols('t')

class MyTestCase(TestCase):
def test3(self):
x = Matrix([exp(t), cos(t), sin(t)])
self.assertNotEqual(Derivative(x, t, 2).doit(), -x)

def test4(self):
x = Matrix([sin(2 * t), log(1 + t), t])
self.assertNotEqual(Derivative(x, t, 2).doit(), -9 * x)

p3 = plot_parametric(cos(t), sin(t), legend=True, show=False)
p3.save('sample6_3.png')

p4 = plot_parametric(cos(3 * t), sin(3 * t), legend=True, show=False)
p4.save('sample6_4.png')

if __name__ == "__main__":
main()


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

----------------------------------------------------------------------
Ran 2 tests in 0.061s

OK
%