## 2019年10月8日火曜日

### 数学 - Python - 代数学 - 実数 - 平方根を含む式の計算 - 二重根号の簡約、分母の有理化、符号

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

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

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

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

5. $\begin{array}{l}\sqrt{5+\sqrt{21}}\\ =\frac{\sqrt{10+2\sqrt{21}}}{\sqrt{2}}\\ =\frac{\sqrt{{\left(\sqrt{7}+\sqrt{3}\right)}^{2}}}{\sqrt{2}}\\ =\frac{\sqrt{7}+\sqrt{3}}{\sqrt{2}}\\ =\frac{\sqrt{14}+\sqrt{3}}{2}\end{array}$

コード

Python 3

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

print('18.')

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

def tearDown(self):
pass

def test(self):
spam = [sqrt(4 - 2 * sqrt(3)),
sqrt(14 + 2 * sqrt(45)),
sqrt(6 - sqrt(32)),
sqrt(15 - 6 * sqrt(6)),
sqrt(5 + sqrt(21))]
egg = [sqrt(3) - 1,
3 + sqrt(5),
2 - sqrt(2),
3 - sqrt(6),
(sqrt(14) + sqrt(6)) / 2]
for s, t in zip(spam, egg):
self.assertEqual((s ** 2).expand(), (t ** 2).expand())
self.assertGreaterEqual(t, 0)

if __name__ == '__main__':
main()


$./sample18.py 18. . ---------------------------------------------------------------------- Ran 1 test in 0.019s OK$