学習環境
- Surface
- Windows 10 Pro (OS)
- Nebo(Windowsアプリ)
- iPad
- MyScript Nebo - MyScript(iPadアプリ(iOS))
- 参考書籍
新装版 数学読本3 (松坂 和夫(著)、岩波書店)の第9章(図形と代数の交錯する世界 - 平面上のベクトル)、9.1(ベクトルとその演算)、ベクトルの内積の問13の解答を求めてみる。
コード
#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import Matrix
print('13.')
e1 = Matrix([1, 0])
e2 = Matrix([0, 1])
class MyTestCase(TestCase):
def test_e1e1(self):
self.assertEqual(e1.dot(e1), 1)
def test_e1e2(self):
self.assertEqual(e1.dot(e2), 0)
def test_e2e2(self):
self.assertEqual(e2.dot(e2), 1)
if __name__ == "__main__":
main()
入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))
% ./sample13.py -v
13.
test_e1e1 (__main__.MyTestCase) ... ok
test_e1e2 (__main__.MyTestCase) ... ok
test_e2e2 (__main__.MyTestCase) ... ok
----------------------------------------------------------------------
Ran 3 tests in 0.001s
OK
%
0 コメント:
コメントを投稿