ベクトルの微分 曲線の長さ、累乗、指数関数、置換積分法、双曲線関数(sinh、cosh)、逆関数、速度ベクトル、積分
続 解析入門 (原書第2版) (S.ラング(著)、松坂 和夫(翻訳)、片山 孝次(翻訳)、岩波書店)の第2章(ベクトルの微分)、2(曲線の長さ)の練習問題3の解答を求めてみる。
-
よって、 求める曲線の長さは
コード
#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import Matrix, Derivative, Rational, log, Integral, sqrt, exp
from sympy.plotting import plot3d_parametric_line
from sympy.abc import t
print('3.')
Xa = Matrix([t, 2 * t, t ** 2])
Xa1 = Derivative(Xa, t, 1).doit()
tsa = (1, 3)
Xb = Matrix([exp(3 * t), exp(-3 * t), 3 * sqrt(2) * t])
Xb1 = Derivative(Xb, t, 1).doit()
tsb = (0, Rational(1, 3))
class Test(TestCase):
def test_a(self):
self.assertEqual(
float(Integral(Xa1.norm(), (t, *tsa)).doit()),
float(
(13 + 3 * sqrt(41)) / 4 +
(13 + 3 * sqrt(41)) / (4 * (77 + 12 * sqrt(41))) +
5 * log((6 + sqrt(41)) / sqrt(5)) / 4 - 5 * log(sqrt(5)) / 4
)
)
p = plot3d_parametric_line(
(*Xa, (t, -5, 1)),
(*Xa, (t, 1, 3)),
(*Xa, (t, 3, 5)),
show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']
for o, color in zip(p, colors):
o.line_color = color
print(o, color)
p.xlabel = 'x'
p.ylabel = 'y'
p.save('sample3_a.png')
p = plot3d_parametric_line(
(*Xb, (t, -1, 0)),
(*Xb, (t, 0, Rational(1, 3))),
(*Xb, (t, Rational(1, 3), 1)),
show=False)
for o, color in zip(p, colors):
o.line_color = color
print(o, color)
p.xlabel = 'x'
p.ylabel = 'y'
p.save('sample3_b.png')
p.show()
if __name__ == "__main__":
main()
入出力結果
% ./sample3.py -v
3.
3D parametric cartesian line: (t, 2*t, t**2) for t over (-5.0, 1.0) red
3D parametric cartesian line: (t, 2*t, t**2) for t over (1.0, 3.0) green
3D parametric cartesian line: (t, 2*t, t**2) for t over (3.0, 5.0) blue
3D parametric cartesian line: (exp(3*t), exp(-3*t), 3*sqrt(2)*t) for t over (-1.0, 0.0) red
3D parametric cartesian line: (exp(3*t), exp(-3*t), 3*sqrt(2)*t) for t over (0.0, 0.3333333333333333) green
3D parametric cartesian line: (exp(3*t), exp(-3*t), 3*sqrt(2)*t) for t over (0.3333333333333333, 1.0) blue
test_a (__main__.Test) ... ok
----------------------------------------------------------------------
Ran 1 test in 0.252s
OK
%