## 2018年10月31日水曜日

### 数学 – Python - 数学はここから始まる - 数 – 2次方程式と複素数 – 複素数の演算(加減乗除、共役な複素数)

1. $-6i$

2. $2+8i$

3. $-36$

4. $\left(10+21\right)-29i=31-29i$

5. $-i$

6. $1$

7. $i$

8. $-1$

9. $\frac{5\left(3+4i\right)}{9+16}=\frac{3}{5}+\frac{4}{5}i$

10. $\frac{\left(-3+2i\right)\left(2-3i\right)}{4+9}=\frac{13i}{13}=i$

11. $\frac{\left(11-16i\right)\left(7-3i\right)}{49+9}=\frac{\left(77-48\right)+\left(-33-112\right)i}{58}=\frac{1}{2}-\frac{145}{58}i=\frac{1}{2}-\frac{5}{2}i$

12. $\frac{{\left(1-i\right)}^{2}}{1+1}=\frac{-2i}{2}=-i$

13. $-i$

14. $\begin{array}{}{\left(1-i\right)}^{4}\\ ={\left(-2i\right)}^{2}\\ =-4\end{array}$

15. $\begin{array}{}\frac{\left(1+2i\right)\left(3+i\right)+\left(1-2i\right)\left(3-i\right)}{9+1}\\ =\frac{1+7i+1-7i}{10}\\ =\frac{1}{5}\end{array}$

16. $\begin{array}{}{\left(\frac{\left(2+i\right)\left(2+i\right)}{4+1}\right)}^{2}\\ ={\left(\frac{3+4i}{5}\right)}^{2}\\ =\frac{9-16}{25}+\frac{24}{25}i\\ =-\frac{7}{25}+\frac{24}{25}i\end{array}$

コード(Emacs)

Python 3

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

print('5.')

zs = [5 / (3 - 4 * I),
(-3 + 2 * I) / (2 + 3 * I),
(11 - 16 * I) / (7 + 3 * I),
(1 - I)/(1 + I),
1 / I,
(1 - I) ** 4,
(1 + 2 * I) / (3 - I) + (1 - 2 * I) / (3 + I),
((2 + I) / (2 - I)) ** 2]

for i, z in enumerate(zs, 9):
print(f'({i})')
pprint(z.expand())
print()


$./sample5.py 5. (9) 3 4⋅ⅈ ─ + ─── 5 5 (10) ⅈ (11) 1 5⋅ⅈ ─ - ─── 2 2 (12) -ⅈ (13) -ⅈ (14) -4 (15) 1/5 (16) 7 24⋅ⅈ - ── + ──── 25 25$