2020年2月14日金曜日

学習環境

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



    1. vt=et,-sint,costX·vt=et,cost,sint·et,-sint,cost=e2t-sintcost+sintcost=e2t

      直交しない。


    2. X·vt=sin2t,log1+t,t·2cos2t,11+t,1=2sin2tcos2t+log1+t1+t+t

      直交しない。


    3. cost,sint·-sint,cost=-costcost+sintcost=0

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


    4. cos3t,sin3t·-3sin3t,3cos3t=-3sin3tcos3t+3sin3tcos3t=0

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

コード

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

t = symbols('t')


class MyTestCase(TestCase):
    def test1(self):
        x = Matrix([exp(t), cos(t), sin(t)])
        self.assertNotEqual(Derivative(x, t, 1).doit().dot(x), 0)

    def test2(self):
        x = Matrix([sin(2 * t), log(1 + t), t])
        self.assertNotEqual(Derivative(x, t, 1).doit().dot(x), 0)

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

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


p1 = plot3d_parametric_line(exp(t), cos(t), sin(t), show=False, legend=True)
p1.save('sample2_1.png')

p2 = plot3d_parametric_line(sin(2 * t), log(1 + t),
                            t, (t, -0.9, 10), show=False, legend=True)
p2.save('sample2_2.png')

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

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

if __name__ == "__main__":
    main()

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

% ./sample5.py -v
5.
test1 (__main__.MyTestCase) ... ok
test2 (__main__.MyTestCase) ... ok
test3 (__main__.MyTestCase) ... ok
test4 (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 4 tests in 0.015s

OK
%

0 コメント:

コメントを投稿