2019年10月26日土曜日

数学 - Python - 代数学 - 実数 - 3つの平方根の和、分数、分母の有理化

1. $\begin{array}{l}\frac{\sqrt{5}-\sqrt{2}}{\sqrt{5}+\sqrt{3}+\sqrt{2}}\\ =\frac{\left(\sqrt{5}-\sqrt{2}\right)\left(\sqrt{5}+\sqrt{2}-\sqrt{3}\right)}{\left(\sqrt{5}+\sqrt{2}+\sqrt{3}\right)\left(\sqrt{5}+\sqrt{2}-\sqrt{3}\right)}\\ =\frac{3-\left(\sqrt{5}-\sqrt{2}\right)\sqrt{3}}{{\left(\sqrt{5}+\sqrt{2}\right)}^{2}-3}\\ =\frac{3-\sqrt{15}+\sqrt{6}}{4+2\sqrt{10}}\\ =\frac{3-\sqrt{15}+\sqrt{6}}{2\left(2+\sqrt{10}\right)}\\ =\frac{\left(3-\sqrt{15}+\sqrt{6}\right)\left(2-\sqrt{10}\right)}{2\left(4-10\right)}\\ =\frac{6-3\sqrt{10}-2\sqrt{15}+\sqrt{3·5·2·5}+2\sqrt{6}-\sqrt{2·3·2·5}}{2\left(-6\right)}\\ =\frac{6-3\sqrt{10}-2\sqrt{15}+5\sqrt{6}+2\sqrt{6}-2\sqrt{15}}{-12}\\ =\frac{6-4\sqrt{15}-3\sqrt{10}+7\sqrt{6}}{-12}\end{array}$

コード

Python 3

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

print('10.')

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

def tearDown(self):
self.assertEqual((sqrt(5) - sqrt(2)) / (sqrt(5) + sqrt(3) + sqrt(2)),
(6 - 4 * sqrt(15) - 3 * sqrt(10) + 7 * sqrt(6)) / (-12))

if __name__ == '__main__':
main()


% ./sample10.py
10.

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
%