2020年6月5日金曜日

学習環境

ラング線形代数学(上) (ちくま学現文庫)(S.ラング (著)、芹沢 正三 (翻訳)、筑摩書房)の6章(行列式)、4(行列式の存在)、練習問題7の解答を求めてみる。


  1. det [ sin t cos t - cos t sin t ] = sin 2 t + cos 2 t = 1

コード

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

print('7.')


class TestMatrixDet(TestCase):
    def test(self):
        t = symbols('t')
        self.assertEqual(Matrix([[sin(t), cos(t)],
                                 [-cos(t), sin(t)]]).det().simplify(),
                         1)


if __name__ == "__main__":
    main()

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

% ./sample7.py
7.
.
----------------------------------------------------------------------
Ran 1 test in 0.417s

OK
%

0 コメント:

コメントを投稿