2020年5月20日水曜日

学習環境

代数への出発 (新装版 数学入門シリーズ) (松坂 和夫(著)、岩波書店)の第5章(連立方程式と高次方程式) 、問14の解答を求めてみる。


  1. a+ωb+ω2ca+ω2b+ωc=a2+aω2+ωb+c+ω3b2+ω2+ω4bc+ω3c2=a2-ab+c+b2+ω2+ωbc+c2=a2+b2+c2-bc-ca-ab

コード

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

print('14.')


class TestExpand(TestCase):
    def test(self):
        x = symbols('x')
        a, b, c = symbols('a:c')
        ws = [w for w in solve(x ** 3 - 1) if not w.is_real]
        for w in ws:
            self.assertEqual(
                a ** 2 + b ** 2 + c ** 2 - b * c - c * a - a * b,
                ((a + w * b + w ** 2 * c) * (a + w ** 2 * b + w * c)).expand()
            )


if __name__ == "__main__":
    main()

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

% ./sample14.py -v
14.
test (__main__.TestExpand) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.077s

OK
%

0 コメント:

コメントを投稿