## 2019年9月11日水曜日

### 数学 - Python - 線形代数学 - 多項式と素因子分解 - 多項式の α - 進展開 - 2-進展開

ラング線形代数学(下) (ちくま学現文庫)(S.ラング (著)、芹沢 正三 (翻訳)、筑摩書房)の12章(多項式と素因子分解)、7(多項式の α - 進展開)、練習問題1の解答を求めてみる。

1. $\begin{array}{l}{t}^{2}-1\\ ={\left(t-2\right)}^{2}+4t-5\\ =3+4\left(t-2\right)+{\left(t-2\right)}^{2}\end{array}$

2. $\begin{array}{l}{t}^{3}+t-1\\ ={\left(t-2\right)}^{3}+6{t}^{2}-12t+8+t-1\\ ={\left(t-2\right)}^{3}+6{t}^{2}-11t+7\\ =6{\left(t-2\right)}^{2}+{\left(t-2\right)}^{3}+24t-24-11t+7\\ =6{\left(t-2\right)}^{2}+{\left(t-2\right)}^{3}+13t-17\\ =9+13\left(t-2\right)+6{\left(t-z\right)}^{2}+{\left(t-2\right)}^{3}\end{array}$

3. $\begin{array}{l}{t}^{2}+3\\ ={\left(t-2\right)}^{2}+4t-1\\ =7+4\left(t-2\right)+{\left(t-2\right)}^{2}\end{array}$

4. $\begin{array}{l}{t}^{4}+2{t}^{3}-t+5\\ ={\left(t-2\right)}^{4}+8{t}^{3}-24{t}^{2}+32t-16+2{t}^{3}-t+5\\ ={\left(t-2\right)}^{4}+10{t}^{3}-24{t}^{2}+31t-11\\ =10{\left(t-2\right)}^{3}+{\left(t-2\right)}^{4}+60{t}^{2}-120t+80-24{t}^{2}+31t-11\\ =10{\left(t-2\right)}^{3}+{\left(t-2\right)}^{4}+36{t}^{2}-89t+69\\ =36{\left(t-2\right)}^{2}+10{\left(t-2\right)}^{3}+{\left(t-2\right)}^{4}+144t-144-89t+69\\ =36{\left(t-2\right)}^{2}+10{\left(t-2\right)}^{3}+{\left(t-2\right)}^{4}+55t-75\\ =35+55\left(t-2\right)+36{\left(t-2\right)}^{2}+10{\left(t-2\right)}^{3}+{\left(t-2\right)}^{4}\end{array}$

コード

Python 3

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

print('1.')

class MyTest(TestCase):
def setUp(self):
pass

def tearDown(self):
pass

def test(self):
t = symbols('t')
coefficients1 = [(-1, 0, 1),
(-1, 1, 0, 1),
(3, 0, 1),
(5, -1, 0, 2, 1)]
coefficients2 = [(3, 4, 1),
(9, 13, 6, 1),
(7, 4, 1),
(35, 55, 36, 10, 1)]

for cs1, cs2 in zip(coefficients1, coefficients2):
self.assertEqual(
sum([c * t ** i for i, c in enumerate(cs1)]),
sum([c * (t - 2) ** i for i, c in enumerate(cs2)]).expand())

if __name__ == '__main__':
main()


C:\Users\...>py sample1.py
1.
.
----------------------------------------------------------------------
Ran 1 test in 0.010s

OK

C:\Users\...>