## 2018年9月27日木曜日

### 数学 – Python - 数学はここから始まる - 数 – 整式 – 共通因数をくくり出すこと(因数分解、応用、色々な工夫)

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

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

3. $\begin{array}{}{\left(x-y\right)}^{2}+5\left(x-y\right)+6\\ =\left(x-y+2\right)\left(x-y+3\right)\end{array}$

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

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

6. $\begin{array}{}\left({x}^{2}-{y}^{2}\right)\left({x}^{2}-25{y}^{2}\right)\\ =\left(x+y\right)\left(x-y\right)\left(x+5y\right)\left(x-5y\right)\end{array}$

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

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

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

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

11. $\begin{array}{}\left({x}^{2}+4x-12\right)\left({x}^{2}+4x+4\right)\\ =\left(x+6\right)\left(x-2\right){\left(x+2\right)}^{2}\end{array}$

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

13. $\begin{array}{}{x}^{2}-\left(y+1\right)x-\left(6{y}^{2}-23y+20\right)\\ ={x}^{2}-\left(y+1\right)x-\left(2y-5\right)\left(3y-4\right)\\ =\left(x+2y-5\right)\left(x-3y+4\right)\end{array}$

14. $\begin{array}{}\left(x-2\right)y+\left(2{x}^{2}-x-6\right)\\ =\left(x-2\right)y+\left(x-2\right)\left(2x+3\right)\\ =\left(x-2\right)\left(2x+y+3\right)\end{array}$

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

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

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

18. $\begin{array}{}{\left(a+1\right)}^{2}+\left(b+c\right)\left(a+1\right)+bc\\ =\left(a+b+1\right)\left(a+c+1\right)\end{array}$

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

20. $\begin{array}{}{\left(a-b\right)}^{3}+{\left(b-c\right)}^{3}+{\left(c-a\right)}^{3}-3\left(a-b\right)\left(b-c\right)\left(c-a\right)+3\left(a-b\right)\left(b-c\right)\left(c-a\right)\\ =0+3\left(a-b\right)\left(b-c\right)\left(c-a\right)\\ =3\left(a-b\right)\left(b-c\right)\left(c-a\right)\end{array}$

コード(Emacs)

Python 3

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

print('13.')

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

ts = [x ** 2 - x - y ** 2 - x,
a ** 2 - c ** 2 + a * b - b * c,
(x - y) * (x - y + 5) + 6,
x ** 3 - x ** 2 * y - x + y,
x ** 4 - 2 * x ** 2 + 1,
x ** 4 - 26 * x ** 2 * y ** 2 + 25 * y ** 4,
a ** 4 + a ** 2 - 20,
a ** 4 - 16 * b ** 4,
16 * x ** 4 - 81 * y ** 4,
x ** 4 + x ** 2 * y ** 2 - 2 * y ** 4,
(x ** 2 + 4 * x) ** 2 - 8 * (x ** 2 + 4 * x) - 48,
2 * x ** 2 + 3 * x * y - 2 * y ** 2 - 4 * x + 7 * y - 6,
x ** 2 - x * y - 6 * y ** 2 - x + 23 * y - 20,
2 * x ** 2 + x * y - x - 2 * y - 6,
a ** 2 + (2 * b - 3) * a - (3 * b ** 2 + b - 2),
a ** 4 + 4,
x ** 4 + x ** 2 + 1,
(a + b + c + 1) * (a + 1) + b * c,
x ** 3 + y ** 3 + 1 - 3 * x * y,
(a - b) ** 3 + (b - c) ** 3 + (c - a) ** 3]

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


$./sample13.py 13. (1) 2 2 x - 2⋅x - y (2) (a - c)⋅(a + b + c) (3) (x - y + 2)⋅(x - y + 3) (4) (x - 1)⋅(x + 1)⋅(x - y) (5) 2 2 (x - 1) ⋅(x + 1) (6) (x - 5⋅y)⋅(x - y)⋅(x + y)⋅(x + 5⋅y) (7) ⎛ 2 ⎞ (a - 2)⋅(a + 2)⋅⎝a + 5⎠ (8) ⎛ 2 2⎞ (a - 2⋅b)⋅(a + 2⋅b)⋅⎝a + 4⋅b ⎠ (9) ⎛ 2 2⎞ (2⋅x - 3⋅y)⋅(2⋅x + 3⋅y)⋅⎝4⋅x + 9⋅y ⎠ (10) ⎛ 2 2⎞ (x - y)⋅(x + y)⋅⎝x + 2⋅y ⎠ (11) 2 (x - 2)⋅(x + 2) ⋅(x + 6) (12) (x + 2⋅y - 3)⋅(2⋅x - y + 2) (13) (x - 3⋅y + 4)⋅(x + 2⋅y - 5) (14) (x - 2)⋅(2⋅x + y + 3) (15) (a - b - 1)⋅(a + 3⋅b - 2) (16) ⎛ 2 ⎞ ⎛ 2 ⎞ ⎝a - 2⋅a + 2⎠⋅⎝a + 2⋅a + 2⎠ (17) ⎛ 2 ⎞ ⎛ 2 ⎞ ⎝x - x + 1⎠⋅⎝x + x + 1⎠ (18) (a + b + 1)⋅(a + c + 1) (19) ⎛ 2 2 ⎞ (x + y + 1)⋅⎝x - x⋅y - x + y - y + 1⎠ (20) -3⋅(a - b)⋅(a - c)⋅(b - c)$