## 2020年3月24日火曜日

### 数学 - Python - 新しい数とその表示ー複素数と複素平面 - 複素平面 - 複素の絶対値 - 等式の証明、実部、虚部

1. $\begin{array}{l}\alpha =a+bi\\ \beta =c+di\\ a,b,c,d\in \text{ℝ}\end{array}$

とおく。

$\begin{array}{l}{\left|\alpha +\beta \right|}^{2}+{\left|\alpha -\beta \right|}^{2}\\ ={\left|\left(a+c\right)+\left(b+d\right)i\right|}^{2}+{\left|\left(a-c\right)+\left(b-d\right)i\right|}^{2}\\ ={\left(a+c\right)}^{2}+{\left(b+d\right)}^{2}+{\left(a-c\right)}^{2}+{\left(b-d\right)}^{2}\\ =2\left({a}^{2}+{c}^{2}+{b}^{2}+{d}^{2}\right)\\ =2\left({a}^{2}+{b}^{2}+{c}^{2}+{d}^{2}\right)\\ =2\left({\left|\alpha \right|}^{2}+{\left|\beta \right|}^{2}\right)\end{array}$

（証明終）

コード

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

print('3.')

class MyTestCase(TestCase):
def test1(self):
a, b, c, d = symbols('a:d', real=True)
alpha = a + b * I
beta = c + d * I
self.assertEqual(abs(alpha + beta) ** 2 + abs(alpha - beta) ** 2,
2 * (abs(alpha) ** 2 + abs(beta) ** 2))

if __name__ == "__main__":
main()

% ./sample3.py -v
3.
test1 (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.073s

OK
%