2020年8月5日水曜日

学習環境

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


  1. X ' ( t ) = ( - a ( sin t ) , a ( cos t ) , b )
    X ' ' ( t ) = ( - a ( cos t ) , - a ( sin t ) , 0 )
    X ' ( t ) = a 2 sin 2 t + a 2 cos 2 t + b 2 = a 2 + b 2
    X ' ' ( t ) = a 2

    よって、 速度ベクトルと加速度ベクトルの長さは一定。

コード

#!/usr/bin/env python3
from sympy import cos, sin, Matrix, Derivative
from sympy.plotting import plot3d_parametric_line, plot3d
from sympy.abc import t

print('22.')

a = 2
b = 3
x = Matrix([a * cos(t), a * sin(t), b * t])
x1 = Derivative(x, t, 1).doit()
colors = ['red', 'green', 'blue', 'brown', 'orange',
          'purple', 'pink', 'gray', 'skyblue', 'yellow']

p = plot3d_parametric_line(*x, legend=False, show=False)
for t0 in range(-5, 6):
    p.append(
        plot3d_parametric_line(
            *(x.subs({t: t0}) + t * x1.subs({t: t0})),
            (t, 0, 1),
            legend=False,
            show=False
        )[0]
    )
p.xlabel = 'x'
p.ylabel = 'y'
for o, color in zip(p, colors):
    o.line_color = color
p.save(f'sample21.png')
p.show()

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

% ./sample22.py
22.
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy/ma/core.py:2831: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  _data = np.array(data, dtype=dtype, copy=copy,
%

0 コメント:

コメントを投稿