## 2020年3月30日月曜日

### 数学 - Python - 新しい数とその表示ー複素数と複素平面 - 複素平面 - 複素数の極形式 - 絶対値、偏角、三角関数(正弦と余弦)

1. $\begin{array}{l}\left|1-i\right|=\sqrt{2}\\ \mathrm{arg}\left(1-i\right)=\frac{7}{4}\pi +2n\pi \end{array}$

よって、 この複素数を極形式で表すと、

$1-i=\sqrt{2}\left(\mathrm{cos}\frac{7}{4}\pi +i\mathrm{sin}\frac{7}{4}\pi \right)$

2. $\begin{array}{l}-1-i\\ =\sqrt{2}\left(\mathrm{cos}\frac{5}{4}\pi +i\mathrm{sin}\frac{5}{4}\pi \right)\end{array}$

3. $\begin{array}{l}1+\sqrt{3}i\\ =2\left(\mathrm{cos}\frac{\pi }{3}+i\mathrm{sin}\frac{\pi }{3}\right)\end{array}$

4. $\begin{array}{l}-\sqrt{3}+i\\ =2\left(\mathrm{cos}\frac{5}{6}\pi +i\mathrm{sin}\frac{5}{6}\pi \right)\end{array}$

5. $i=i\mathrm{sin}\frac{\pi }{2}$

6. $-2i=2i\mathrm{sin}\frac{3}{2}\pi$

7. $-3=3\mathrm{cos}\pi$

8. $\begin{array}{l}\frac{1}{\sqrt{2}}-\frac{1}{\sqrt{2}}i\\ =\mathrm{cos}\frac{7}{4}\pi +i\mathrm{sin}\frac{7}{4}\pi \end{array}$

コード

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

print('7.')

class MyTestCase(TestCase):
def test(self):
zs = [(1, -1),
(-1, -1),
(1, sqrt(3)),
(-sqrt(3), 1),
(0, 1),
(0, -2),
(-3, 0),
(1 / sqrt(2), -1 / sqrt(2))]
ras = [(sqrt(2), 7 * pi / 4),
(sqrt(2), 5 * pi / 4),
(2, pi / 3),
(2, 5 * pi / 6),
(1, pi / 2),
(2, 3 * pi / 2),
(3, pi),
(1, 7 * pi / 4)]
for (a, b), (r, arg) in zip(zs, ras):
self.assertEqual(a + b * I,
(r * (cos(arg) + I * sin(arg))).expand())

if __name__ == "__main__":
main()


% ./sample7.py -v
7.
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.064s

OK
%