2020年1月26日日曜日

学習環境

新装版 数学読本3 (松坂 和夫(著)、岩波書店)の第9章(図形と代数の交錯する世界 - 平面上のベクトル)、9.1(ベクトルとその演算)、ベクトルの成分の問9の解答を求めてみる。


  1. a a = 5 , - 12 25 + 144 = 5 13 , - 12 13

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import Matrix, symbols, Rational

print('9.')


class MyTestCase(TestCase):
    def test(self):
        a = Matrix([5, -12])
        self.assertEqual(
            a / a.norm(), Matrix([Rational(5, 13), -Rational(12, 13)]))


if __name__ == '__main__':
    main()

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

% ./sample9.py -v
9.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.047s

OK
%

0 コメント:

コメントを投稿