## 2020年7月22日水曜日

### 数学 - Python - 解析学 - ベクトルの微分 - 微分係数 - 速度ベクトル、垂直、法線

1. $\left(x,y\right)=\left(\mathrm{cos}\frac{\pi }{3},\mathrm{sin}\frac{\pi }{3}\right)+t\left(\mathrm{cos}\frac{\pi }{3},\mathrm{sin}\frac{\pi }{3}\right)$
$\left(x,y\right)=\left(\frac{1}{2},\frac{\sqrt{3}}{2}\right)+t\left(\frac{1}{2},\frac{\sqrt{3}}{2}\right)$

2. $\left(x,y\right)=\left(\mathrm{cos}3·\frac{\pi }{3},\mathrm{sin}3·\frac{\pi }{3}\right)+t\left(\mathrm{cos}3·\frac{\pi }{3},\mathrm{sin}3·\frac{\pi }{3}\right)$
$\left(x,y\right)=\left(-1,0\right)+t\left(-1,0\right)$

コード

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

print('8.')

a = Matrix([cos(t), sin(t)])
b = Matrix([cos(3 * t), sin(3 * t)])

class Test(TestCase):
def test3(self):
self.assertEqual(
Derivative(a, t, 1).doit().dot(a), 0
)

def test4(self):
self.assertEqual(
Derivative(b, t, 1).doit().dot(b), 0
)

p = plot_parametric(
(cos(t), sin(t), (t, 0, 2 * pi)),
(cos(pi / 3) + t * -sin(pi / 3),
sin(pi / 3) + t * cos(pi / 3),
(t, 0, 1)),
(t * cos(pi / 3), t * sin(pi / 3), (t, -1, 1)),
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.save('sample8_3.png')
p = plot_parametric(
(cos(3 * t), sin(3 * t), (t, 0, 2 * pi / 3)),
(cos(3 * pi / 3) + t * -3 * sin(3 * pi / 3),
sin(3 * pi / 3) + t * 3 * cos(3 * pi / 3),
(t, 0, 1)),
(-1 * t, 0, (t, -1, 1)),
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.save('sample8_4.png')
p.show()
if __name__ == "__main__":
main()


% ./sample8.py -v
8.
test3 (__main__.Test) ... ok
test4 (__main__.Test) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.006s

OK
%