## 2020年5月18日月曜日

### 数学 - Python - 代数学 - 連立方程式と高次方程式 - 1の虚立方根、2変数、3次式、差、展開

1. $\begin{array}{l}{x}^{3}-{y}^{3}\\ =\left(x-y\right)\left({x}^{2}+xy+{y}^{2}\right)\\ \left(x-\omega y\right)\left(x-{\omega }^{2}y\right)\\ ={x}^{2}-\left({\omega }^{2}+\omega \right)xy+{\omega }^{3}{y}^{2}\\ ={x}^{2}-\left({\omega }^{2}+\omega \right)xy+{y}^{2}\\ {\omega }^{3}-1=0\\ \left(\omega -1\right)\left({\omega }^{2}+\omega +1\right)=0\\ {\omega }^{2}+\omega +1=0\\ {\omega }^{2}+\omega =-1\\ \left(x-\omega y\right)\left(x-{\omega }^{2}y\right)={x}^{2}+xy+{y}^{2}\end{array}$

よって、

${x}^{3}-{y}^{3}=\left(x-y\right)\left(x-\omega y\right)\left(x-{\omega }^{2}y\right)$

コード

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

print('12.')

x, y = symbols('x, y')
omega = symbols('ω')

class TestExpand(TestCase):
def test(self):
omegas = [o for o in solve(omega ** 3 - 1) if not o.is_real]
for o in omegas:
self.assertEqual(
x ** 3 - y ** 3,
((x - y) * (x - o * y) * (x - o ** 2 * y)).expand()
)

if __name__ == "__main__":
main()


% ./sample12.py -v
12.
test (__main__.TestExpand) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.096s

OK
%