## 2020年5月20日水曜日

### 数学 - Python - 代数学 - 連立方程式と高次方程式 - 1の虚立方根、3変数、2次、等式の証明

1. $\begin{array}{l}\left(a+\omega b+{\omega }^{2}c\right)\left(a+{\omega }^{2}b+\omega c\right)\\ ={a}^{2}+a\left({\omega }^{2}+\omega \right)\left(b+c\right)+{\omega }^{3}{b}^{2}+\left({\omega }^{2}+{\omega }^{4}\right)bc+{\omega }^{3}{c}^{2}\\ ={a}^{2}-a\left(b+c\right)+{b}^{2}+\left({\omega }^{2}+\omega \right)bc+{c}^{2}\\ ={a}^{2}+{b}^{2}+{c}^{2}-bc-ca-ab\end{array}$

コード

#!/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()


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

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

OK
%