## 2019年3月31日日曜日

### 数学 - Python - 解析学 - 数 - 複素数(和の絶対値、差の絶対値、和、共役、等式の証明)

1. $\begin{array}{}{\left|\alpha +\beta \right|}^{2}+{\left|\alpha -\beta \right|}^{2}\\ =\left(\alpha +\beta \right)\stackrel{-}{\left(\alpha +\beta \right)}+\left(\alpha -\beta \right)\left(\stackrel{-}{\alpha -\beta }\right)\\ =\left(\alpha +\beta \right)\left(\stackrel{-}{\alpha }+\stackrel{-}{\beta }\right)+\left(\alpha -\beta \right)\left(\stackrel{-}{\alpha }-\stackrel{-}{\beta }\right)\\ ={\left|\alpha \right|}^{2}+\alpha \stackrel{-}{\beta }+\stackrel{-}{\alpha }\beta +{\left|\beta \right|}^{2}+\\ {\left|\alpha \right|}^{2}-\alpha \stackrel{-}{\beta }-\stackrel{-}{\alpha }\beta +{\left|\beta \right|}^{2}\\ =2\left({\left|\alpha \right|}^{2}+{\left|\beta \right|}^{2}\right)\end{array}$

コード

Python 3

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

print('4.')

# 上手くいかず
a, b = symbols('a, b', imag=True)
l = abs(a + b) ** 2 + abs(a - b) ** 2
r = 2 * (abs(a) ** 2 + abs(b) ** 2)

for o in [l, r, (l - r).expand() == 0]:
pprint(o)
print()

# 実数で構築
a, b, c, d = symbols('a, b, c, d', real=True)
alpha = a + b * I
beta = c + d * I

l = abs(alpha + beta) ** 2 + abs(alpha - beta) ** 2
r = 2 * (abs(alpha) ** 2 + abs(beta) ** 2)
for o in [l, r, l == r]:
pprint(o)
print()


C:\Users\...>py -3 sample4.py
4.
2          2
│a - b│  + │a + b│

2        2
2⋅│a│  + 2⋅│b│

False

2      2      2      2
2⋅a  + 2⋅b  + 2⋅c  + 2⋅d

2      2      2      2
2⋅a  + 2⋅b  + 2⋅c  + 2⋅d

True

C:\Users\...>