2020年1月12日日曜日

学習環境

解析入門 原書第3版 (S.ラング(著)、松坂 和夫(翻訳)、片山 孝次(翻訳)、岩波書店)の第Ⅵ部(多変数の関数)、第17章(ベクトル)、4(ベクトルのノルム)の練習問題11の解答を求めてみる。


  1. A + c B = A + c B · A + c B = A 2 + 2 c A · B + c 2 B 2 = A 2 + c 2 B 2 A 2 = A 2

コード

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

print('11.')


class MyTestCase(TestCase):
    def test(self):
        a = Matrix([1, 0])
        b = Matrix([0, 1])
        c = symbols('c')
        self.assertGreaterEqual((a + c * b).norm() ** 2, a.norm() ** 2)


if __name__ == '__main__':
    main()

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

% ./sample11.py -v
11.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.044s

OK
%

0 コメント:

コメントを投稿