## 2018年9月21日金曜日

### 数学 – Python - 数学はここから始まる - 数 – 整式 – 共通因数をくくり出すこと(因数分解、応用(和の平方、差の平方、和と差の積))

1. ${\left(5x-2\right)}^{2}$

2. ${\left(2a+3\right)}^{2}$

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

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

5. $\begin{array}{}\left({a}^{2}-{b}^{2}\right)\left({a}^{2}+{b}^{2}\right)\\ =\left(a+b\right)\left(a-b\right)\left({a}^{2}+{b}^{2}\right)\end{array}$

6. $\begin{array}{}\left({a}^{2}+{b}^{2}-{c}^{2}-2ab\right)\left({a}^{2}+{b}^{2}-{c}^{2}+2ab\right)\\ =\left({\left(a-b\right)}^{2}-{c}^{2}\right)\left({\left(a+b\right)}^{2}-{c}^{2}\right)\\ =\left(a-b-c\right)\left(a-b+c\right)\left(a+b-c\right)\left(a+b+c\right)\end{array}$

コード(Emacs)

Python 3

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

print('10.')

x, y, a, b, c = symbols('x, y, a, b, c')

ts = [25 * x ** 2 - 20 * x + 4,
4 * a ** 2 + 12 * a + 9,
36 - 9 * a ** 2,
x ** 2 * y ** 2 - x ** 2 - y ** 2 + 1,
a ** 4 - b ** 4,
(a ** 2 + b ** 2 - c ** 2) ** 2 - 4 * a ** 2 * b ** 2]

for i, t in enumerate(ts, 1):
print(f'({i})')
pprint(t.factor())
print()


$./sample10.py 10. (1) 2 (5⋅x - 2) (2) 2 (2⋅a + 3) (3) -9⋅(a - 2)⋅(a + 2) (4) (x - 1)⋅(x + 1)⋅(y - 1)⋅(y + 1) (5) ⎛ 2 2⎞ (a - b)⋅(a + b)⋅⎝a + b ⎠ (6) (a - b - c)⋅(a - b + c)⋅(a + b - c)⋅(a + b + c)$