2020年3月5日木曜日

学習環境

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


  1. X't=21+t2-2t·2t1+t22,-2t1+t2-1-t2·2t1+t22,0=21-t21+t22,-4t1+t22,0

    よって、 曲線と速度ベクトルの余弦は、

    cosθ=Xt·X'tXtX'tXt·X't=2t1+t2,1-t21+t2,1·21-t21+t22,-4t1+t22,0=21+t232t1-t2-2t1-t2=0

    よって、 余弦は定数である。

    .

    (証明終)

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import symbols, Matrix, Derivative
from sympy.plotting import plot_parametric
print('24.')

t, a, b = symbols('t, a, b', real=True)
x = Matrix([2 * t / (1 + t ** 2),
            (1 - t ** 2) / (1 + t ** 2),
            1])
x1 = Derivative(x, t, 1).doit()


class MyTestCase(TestCase):
    def test(self):
        self.assertEqual(x.dot(x1).simplify(), 0)


p = plot_parametric(*x[:2],
                    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('sample24.png')


if __name__ == "__main__":
    main()

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

% ./sample24.py -v
24.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.327s

OK
%

0 コメント:

コメントを投稿