## 2019年12月19日木曜日

### 数学 - Python - 代数学 - 整式の計算 - 割り算、一つの変数に着目する

1. $\begin{array}{l}A\\ ={x}^{3}\left(y-z\right)+{y}^{3}\left(z-x\right)+{z}^{3}\left(x-y\right)\\ =\left(y-z\right){x}^{3}-\left({y}^{3}-{z}^{3}\right)x+\left({y}^{3}z-y{z}^{3}\right)\\ B=x+\left(y+z\right)\end{array}$

よって、

$\begin{array}{l}A\\ =\left(x+y+z\right)\left(\left(y-z\right){x}^{2}-\left({y}^{2}-{z}^{2}\right)x+{y}^{2}z-y{z}^{2}\right)\\ =\left(y-z\right)\left(x+y+z\right)\left({x}^{2}-\left(y+z\right)x+yz\right)\\ =\left(x-y\right)\left(x-z\right)\left(y-z\right)\left(x+y+z\right)\\ =-\left(x-y\right)\left(y-z\right)\left(z-x\right)\left(x+y+z\right)\end{array}$

コード

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

print('12.')

class MyTest(TestCase):
def test(self):
x, y, z = symbols('x, y, z')
a = x ** 3 * (y - z) + y ** 3 * (z - x) + z ** 3 * (x - y)
b = x + y + z
self.assertEqual(
a.expand(), (-(x - y) * (y - z) * (z - x) * b).expand())

if __name__ == '__main__':
main()


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

----------------------------------------------------------------------
Ran 1 test in 0.015s

OK
%