学習環境
- Surface
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
解析入門 原書第3版 (S.ラング(著)、松坂 和夫(翻訳)、片山 孝次(翻訳)、岩波書店)の第Ⅵ部(多変数の関数)、第17章(ベクトル)、4(ベクトルのノルム)の練習問題9の解答を求めてみる。
よって、
(証明終)
コード
#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import symbols, Matrix
print('9.')
a = Matrix([1, 2, 3])
b = Matrix([-4, 5, -6])
cos_theta = a.dot(b) / (a.norm() * b.norm())
class DistanceTestCase(TestCase):
def test(self):
self.assertEqual((a - b).norm() ** 2,
a.norm() ** 2 + b.norm() ** 2 - 2 * a.norm() * b.norm() * cos_theta)
if __name__ == '__main__':
main()
入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))
% ./sample9.py -v
9.
test (__main__.DistanceTestCase) ... ok
----------------------------------------------------------------------
Ran 1 test in 0.003s
OK
%
0 コメント:
コメントを投稿