## 2020年2月10日月曜日

### 数学 - Python - 代数学 - 1次方程式, 2次方程式 - 2次方程式 - 完全平方式

1. $\begin{array}{l}{\left(4x+a\right)}^{2}\\ =16{x}^{2}+8ax+{a}^{2}\\ 8a=-72\\ a=-9\end{array}$

よって、

$16{x}^{2}-72x+81={\left(4x-9\right)}^{2}$

2. ${\left(\frac{1}{2}·\frac{1}{2}\right)}^{2}=\frac{1}{16}$

3. $\begin{array}{l}2\sqrt{9{y}^{2}}a=-24xy\\ 6ya=-24xy\\ a=-4x\\ 16{x}^{2}\end{array}$

4. ${\left(-\frac{1}{2}b·\frac{1}{2}\right)}^{2}=\frac{1}{4}{b}^{2}$

5. ${\left(\frac{5}{4}by\frac{1}{2}\right)}^{2}=\frac{25}{64}{b}^{2}{y}^{2}$

6. $\begin{array}{l}{\left(\frac{1}{2}·8\left(x-y\right)\right)}^{2}\\ =16{\left(x-y\right)}^{2}\end{array}$

7. $\begin{array}{l}2\sqrt{4{x}^{2}}\sqrt{25{y}^{2}}\\ =20xy\end{array}$

8. $\begin{array}{l}2\sqrt{\frac{1}{4}{\left(a+b\right)}^{2}{x}^{2}}\sqrt{9{y}^{4}}\\ =2·\frac{1}{2}\left(a+b\right)x·3{y}^{2}\\ =3\left(a+b\right)x{y}^{2}\end{array}$

コード

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

print('11.')

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

exprs = [16 * x ** 2 - 72 * + 81,
x ** 2 + x / 2 + Rational(1, 16),
16 * x ** 2 - 24 * x * y + 9 * y ** 2,
a ** 2 - a * b + b ** 2 / 4,
a ** 2 * x ** 2 + 5 * a * b * x * y / 4 + 25 * b ** 2 * y ** 2 / 64,
(x + y) ** 2 + 8 * (x ** 2 - y ** 2) + 16 * (x - y) ** 2,
4 * x ** 2 + 20 * x * y + 25 * y ** 2,
(a + b) ** 2 * x ** 2 / 4 - 3 * (a + b) * x * y ** 2 + 9 * y ** 4]

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


% ./sample11.py
11.
(1)
⎛   2      ⎞
8⋅⎝2⋅x  - 729⎠

(2)
2
(4⋅x + 1)
──────────
16

(3)
2
(4⋅x - 3⋅y)

(4)
2
(2⋅a - b)
──────────
4

(5)
2
(8⋅a⋅x + 5⋅b⋅y)
────────────────
64

(6)
2
(5⋅x - 3⋅y)

(7)
2
(2⋅x + 5⋅y)

(8)
2
⎛               2⎞
⎝a⋅x + b⋅x - 6⋅y ⎠
───────────────────
4

%