学習環境
解析入門
原書第3版 (S.ラング(著)、松坂
和夫(翻訳)、片山
孝次(翻訳)、岩波書店)の第Ⅵ部(多変数の関数)、第18章(ベクトルの微分)、1(微分係数)の練習問題5の解答を求めてみる。
#!/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()
0 コメント:
コメントを投稿