## 2019年10月2日水曜日

### 数学 - Python - 代数学 - 実数 - 平方根を含む式の計算 - 和、差、積、商、変形、素因数分解、累乗

1. $\begin{array}{l}4\sqrt{8}-\sqrt{18}-\sqrt{50}\\ =4\sqrt{{2}^{3}}-\sqrt{2·{3}^{2}}-\sqrt{2·{5}^{2}}\\ =8\sqrt{2}-3\sqrt{2}-5\sqrt{2}\\ =0\end{array}$

2. $\begin{array}{l}\sqrt{175}-\sqrt{63}\\ =\sqrt{{5}^{2}·7}-\sqrt{{3}^{2}·7}\\ =5\sqrt{7}-3\sqrt{7}\\ =2\sqrt{7}\end{array}$

3. $\begin{array}{l}3\sqrt{54}-2\sqrt{24}-\sqrt{96}\\ =3\sqrt{2·{3}^{3}}-2\sqrt{{2}^{3}·3}-\sqrt{{2}^{5}·3}\\ =9\sqrt{6}-4\sqrt{6}-4\sqrt{6}\\ =\sqrt{6}\end{array}$

4. $\begin{array}{l}\sqrt{20}-3\sqrt{2}+3\sqrt{45}-\sqrt{50}\\ =\sqrt{{2}^{2}·5}-3\sqrt{2}+3\sqrt{{3}^{2}·5}-\sqrt{2·{5}^{2}}\\ =2\sqrt{5}-3\sqrt{2}+9\sqrt{5}-5\sqrt{2}\\ =-8\sqrt{2}+11\sqrt{5}\end{array}$

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

6. $\begin{array}{l}\sqrt{6}\left(\sqrt{3}+\sqrt{4}\right)\\ \sqrt{2·3}\left(\sqrt{3}+2\right)\\ =3\sqrt{2}+2\sqrt{6}\end{array}$

7. $\begin{array}{l}{\left(3\sqrt{2}+2\sqrt{3}\right)}^{2}\\ =18+12+12\sqrt{6}\\ =30+12\sqrt{6}\end{array}$

8. $\begin{array}{l}\left(2\sqrt{7}-3\right)\left(2\sqrt{7}+3\right)\\ =28-9\\ =19\end{array}$

9. $\begin{array}{l}\left(\sqrt{8}+\sqrt{3}\right)\left(2\sqrt{3}-\sqrt{2}\right)\\ =\left(2\sqrt{2}+\sqrt{3}\right)\left(2\sqrt{3}-\sqrt{2}\right)\\ =4\sqrt{6}-4+6-\sqrt{6}\\ =2+3\sqrt{6}\end{array}$

コード

Python 3

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

print('15.')

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

def tearDown(self):
pass

def test(self):
spam = [4 * sqrt(8) - sqrt(18) - sqrt(50),
sqrt(175) - sqrt(63),
3 * sqrt(54) - 2 * sqrt(24) - sqrt(96),
sqrt(20) - 3 * sqrt(2) + 3 * sqrt(45) - sqrt(50),
(sqrt(3) - sqrt(2)) ** 2,
sqrt(6) * (sqrt(3) + sqrt(4)),
(3 * sqrt(2) + 2 * sqrt(3)) ** 2,
(2 * sqrt(7) - 3) * (2 * sqrt(7) + 3),
(sqrt(8) + sqrt(3)) * (2 * sqrt(3) - sqrt(2))]
egg = [0,
2 * sqrt(7),
sqrt(6),
-8 * sqrt(2) + 11 * sqrt(5),
5 - 2 * sqrt(6),
3 * sqrt(2) + 2 * sqrt(6),
30 + 12 * sqrt(6),
19,
2 + 3 * sqrt(6)]
for s, t in zip(spam, egg):
self.assertEqual((s - t).simplify(), 0)

if __name__ == '__main__':
main()


$./sample15.py 15. . ---------------------------------------------------------------------- Ran 1 test in 0.294s OK$