## 2018年9月8日土曜日

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

ラング線形代数学(下)(S.ラング (著)、芹沢 正三 (翻訳)、ちくま学芸文庫)の12章(多項式と素因子分解)、7(多項式のα-進展開)、練習問題1-(a)、(b)、(c)、(d).を取り組んでみる。

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

2. $\begin{array}{}{t}^{3}+t-1\\ ={c}_{0}+{c}_{1}\left(t-2\right)+{c}_{2}{\left(t-2\right)}^{2}+{\left(t-2\right)}^{3}\\ -6+{c}_{2}=0\\ {c}_{2}=6\\ 12-24+{c}_{1}=1\\ {c}_{1}=13\\ -8+24-26+{c}_{0}=-1\\ {c}_{0}=9\\ 9+13\left(t-2\right)+6{\left(t-2\right)}^{2}+{\left(t-2\right)}^{3}\end{array}$

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

4. $\begin{array}{}{c}_{0}+{c}_{1}\left(t-2\right)+{c}_{2}{\left(t-2\right)}^{2}+{c}_{3}{\left(t-2\right)}^{3}+{\left(t-2\right)}^{4}\\ -8+{c}_{3}=2\\ {c}_{3}=10\\ 24-60+{c}_{2}=0\\ {c}_{2}=36\\ -32+120-144+{c}_{1}=-1\\ {c}_{1}=55\\ 16-80+144-110+{c}_{0}=5\\ {c}_{0}=35\\ 35+55\left(t-2\right)+36{\left(t-z\right)}^{2}+10{\left(t-2\right)}^{3}+{\left(t-2\right)}^{4}\end{array}$

コード(Emacs)

Python 3

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

print('1.')

t = symbols('t')
ps = [(t ** 2 - 1, [3, 4, 1]),
(t ** 3 + t - 1, [9, 13, 6, 1]),
(t ** 2 + 3, [7, 4, 1]),
(t ** 4 + 2 * t ** 3 - t + 5, [35, 55, 36, 10, 1])]

for i, (a, b) in enumerate(ps):
print(f'({chr(ord("a") + i)})')
eq = sum([c * (t - 2) ** k for k, c in enumerate(b)])
for s in [a, eq, a == eq.expand()]:
pprint(s)
print()
print()


$./sample1.py 1. (a) 2 t - 1 2 4⋅t + (t - 2) - 5 True (b) 3 t + t - 1 3 2 13⋅t + (t - 2) + 6⋅(t - 2) - 17 True (c) 2 t + 3 2 4⋅t + (t - 2) - 1 True (d) 4 3 t + 2⋅t - t + 5 4 3 2 55⋅t + (t - 2) + 10⋅(t - 2) + 36⋅(t - 2) - 75 True$