2020年3月2日月曜日

学習環境

解析入門 原書第3版 (S.ラング(著)、松坂 和夫(翻訳)、片山 孝次(翻訳)、岩波書店)の第Ⅵ部(多変数の関数)、第18章(ベクトルの微分)、1(微分係数)の練習問題21の解答を求めてみる。


  1. X t = a cos t , a sin t , b t X ' t = - a sin t , a cos t , b

    よって、 曲線上の点 t における接線の向き は

    - a sin t , a cos t , b

    また z 軸の 向きは

    0 , 0 , 1

    よって、 接線と z 軸とのなす角の余弦は

    cos θ t = - a sin t , a cos t , b · 0 , 0 , 1 - a sin t , a cos t , b 0 , 0 , 1 = b a 2 + b 2

    (証明終)

コード

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

print('21.')

a = 2
b = 3
t = symbols('t')
x = Matrix([a * cos(t), a * sin(t), b * t])
x1 = Derivative(x, t, 1).doit()
ts = [-2, 3]
ls = [x.subs({t: t0}) + t * x1.subs({t: t0}) for t0 in [-2, 3]]
z = Matrix([0, 0, 1])


class MyTestCase(TestCase):
    def test(self):
        self.assertEqual(x1, Matrix([-a * sin(t), a * cos(t), b]))


p = plot3d_parametric_line(*[(*s, (t, -20, 20)) for s in [x] + ls],
                           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('sample21.png')

if __name__ == "__main__":
    main()

入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))

% ./sample21.py -v
21.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.001s

OK
%

0 コメント:

コメントを投稿