## 2020年5月16日土曜日

### 数学 - Python - 代数学 - 連立方程式と高次方程式 - 整式、剰余、因数定理

1. $\begin{array}{l}2{x}^{2}-3x-5=\left(x+1\right)\left(2x-5\right)\\ \left\{\begin{array}{l}-4+a-b-25=0\\ 4·{\left(\frac{5}{2}\right)}^{3}+{\left(\frac{5}{2}\right)}^{2}a+\frac{5}{2}b-25=0\end{array}\\ a-b=29\\ \frac{{5}^{3}}{2}+\frac{{5}^{2}}{{2}^{2}}a+\frac{5}{2}b-25=0\\ 2·{5}^{2}+5a+2b-20=0\\ 5a+2b=-30\\ 2a-2b=58\\ 7a=28\\ a=4\\ b=-25\end{array}$

コード

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

print('10.')

class TestRemainder(TestCase):
def test(self):
x = symbols('x')
a = 4
b = -25
f = 4 * x ** 3 + a * x ** 2 + b * x - 25
self.assertEqual(2 * x ** 2 - 3 * x - 5,
((x + 1) * (2 * x - 5)).expand())
self.assertTrue(f.subs({x: -1}) == 0 and
f.subs({x: Rational(5, 2)}) == 0)

if __name__ == "__main__":
main()


% ./sample10.py -v
10.
test (__main__.TestRemainder) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.041s

OK
%