## 2020年2月14日金曜日

### 数学 - Python - 代数学 - 1次方程式, 2次方程式 - 解の公式、解の虚実 - 平方根、加減乗除

1.

1. $\begin{array}{l}\sqrt{-4}+\sqrt{-9}\\ =\sqrt{4}i+\sqrt{9}i\\ =2i+3i\\ =5i\end{array}$

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

3. $\begin{array}{l}\sqrt{2}i2\sqrt{2}\\ =4i\end{array}$

4. $\begin{array}{l}\sqrt{11·5}i\sqrt{11}i\\ =-11\sqrt{5}\end{array}$

5. $\begin{array}{l}\sqrt{6}i\sqrt{3}i\sqrt{2}i\\ =-6i\end{array}$

6. $\begin{array}{l}\frac{\sqrt{27}}{\sqrt{3}i}\\ =\frac{3}{i}\\ =-3i\end{array}$

7. $\begin{array}{l}\frac{\sqrt{27}i}{\sqrt{3}}\\ =3i\end{array}$

8. $\begin{array}{l}\frac{2\sqrt{3}i}{2\sqrt{2}i}\\ =\sqrt{\frac{3}{2}}\\ =\frac{\sqrt{6}}{2}\end{array}$

コード

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

print('15.')

class MyTestCase(TestCase):
def test(self):
exprs = [sqrt(-4) + sqrt(-9),
sqrt(-12) + sqrt(-18) - sqrt(-72) - sqrt(-48),
sqrt(-2) * sqrt(8),
sqrt(-55) * sqrt(-11),
sqrt(-6) * sqrt(-3) * sqrt(-2),
sqrt(27) / sqrt(-3),
sqrt(-27) / sqrt(3),
sqrt(-12) / sqrt(-8)]
zs = [5 * I,
(-2 * sqrt(3) - 3 * sqrt(2)) * I,
4 * I,
-11 * sqrt(5),
-6 * I,
-3 * I,
3 * I,
sqrt(6) / 2]
for i, (expr, z) in enumerate(zip(exprs, zs), 1):
print(f'({i})')
self.assertEqual(expr.simplify(), z.simplify())

if __name__ == "__main__":
main()


% ./sample15.py -v
15.
test (__main__.MyTestCase) ... (1)
(2)
(3)
(4)
(5)
(6)
(7)
(8)
ok

----------------------------------------------------------------------
Ran 1 test in 0.424s

OK
%