2020年7月31日金曜日

学習環境

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


  1. X ' ( t ) = 2 e 2 t A - 2 e - 2 t B
    X ' ' ( t ) = 4 e 2 t A + 4 e - 2 t B = 4 X ( t )

    よって、 加速度ベクトルは

    X ( t )

    と同じ向きをもつ。

    (証明終)

コード

#!/usr/bin/env python3
from sympy import Matrix, Derivative, exp, pprint
from sympy.plotting import plot3d_parametric_line
from sympy.abc import t

print('17.')

a = Matrix([1, -1, 2])
b = Matrix([3, 4, -1])
x = exp(2 * t) * a + exp(-2 * t) * b
x2 = Derivative(x, t, 2).doit()
for o in [x, x2]:
    pprint(o)
colors = ['red', 'green', 'blue', 'brown', 'orange',
          'purple', 'pink', 'gray', 'skyblue', 'yellow']
p = plot3d_parametric_line(
    (*x, (t, -2, 2)),
    *[(*(x.subs({t: t0}) + t * x2.subs({t: t0})), (t, 0, 1))
      for t0 in range(-2, 3)],
    show=False,
    legend=False,
)
for o, color in zip(p, colors):
    o.line_color = color
p.save(f'sample17.png')
p.show()

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

% ./sample17.py
17.
⎡  2⋅t      -2⋅t ⎤
⎢ ℯ    + 3⋅ℯ     ⎥
⎢                ⎥
⎢   2⋅t      -2⋅t⎥
⎢- ℯ    + 4⋅ℯ    ⎥
⎢                ⎥
⎢    2⋅t    -2⋅t ⎥
⎣ 2⋅ℯ    - ℯ     ⎦
⎡   ⎛ 2⋅t      -2⋅t⎞ ⎤
⎢ 4⋅⎝ℯ    + 3⋅ℯ    ⎠ ⎥
⎢                    ⎥
⎢  ⎛   2⋅t      -2⋅t⎞⎥
⎢4⋅⎝- ℯ    + 4⋅ℯ    ⎠⎥
⎢                    ⎥
⎢   ⎛   2⋅t    -2⋅t⎞ ⎥
⎣ 4⋅⎝2⋅ℯ    - ℯ    ⎠ ⎦
%

0 コメント:

コメントを投稿