## 2016年9月1日木曜日

### 数学 – JavaScript - 新しい数とその表示 - 複素数と複素平面 – 複素平面(複素数の絶対値)

1. $2·\sqrt{10}\sqrt{20}\sqrt{2}=40$

2. $\frac{\sqrt{5}\sqrt{13}}{\sqrt{2}·5}=\frac{\sqrt{130}}{10}$

$\begin{array}{l}{|\alpha +\beta |}^{2}+{|\alpha -\beta |}^{2}\\ =\left(\alpha +\beta \right)\overline{\left(\alpha +\beta \right)}+\left(\alpha -\beta \right)\overline{\left(\alpha -\beta \right)}\\ =\left(\alpha +\beta \right)\left(\overline{\alpha }+\overline{\beta }\right)+\left(\alpha -\beta \right)\left(\overline{\alpha }-\overline{\beta }\right)\\ =\alpha \overline{\alpha }+\beta \overline{\beta }\\ ={|\alpha |}^{2}+{|\beta |}^{2}\end{array}$

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

number.js で確認。

JavaScript

コード(Emacs)

 (function () { 'use strict'; var div_output = document.querySelector('#output0'), button_calc = document.querySelector('#calc0'), nl = '<br>', calc; calc = function () { var a, b, c, d, left, right, n, one = 1, two = 2, output0 = '', output1 = ''; output0 += '問2' + nl; a = new Complex(0, -2); b = new Complex(3, 1); c = new Complex(2, -4); d = new Complex(1, 1); n = a.mul(b).mul(c).mul(d).abs(); output0 += '(1) $<mn>' + n + '</mn>$' + nl; a = new Complex(-1, 2); b = new Complex(3, -2); c = new Complex(1, 1); d = new Complex(3, -4); n = a.mul(b).div(c).div(d).abs(); output1 += ' (2) $<mn>' + n + '</mn>$' + nl + nl; a = new Complex(Math.floor(Math.random() * 100), Math.floor(Math.random() * 100)); b = new Complex(Math.floor(Math.random() * 100), Math.floor(Math.random() * 100)); left = Math.pow(a.add(b).abs(), 2); left = left.add(Math.pow(a.sub(b).abs(), 2)); right = two.mul(Math.pow(a.abs(), 2).add(Math.pow(b.abs(), 2))); output1 += '問3' + nl + 'a = ' + a + ', b = ' + b + nl + '左辺 = 右辺: ' + left.isEqual(right) + nl + '差: ' + left.sub(right) + nl + nl; a = new Complex(0.6, 0.8); b = new Complex(Math.floor(Math.random() * 100), Math.floor(Math.random() * 100)); left = a.sub(b).abs(); right = one.sub(a.conjugate().mul(b)).abs(); output1 += '問4' + nl + 'a = ' + a + ', b = ' + b + nl + '左辺 = 右辺: ' + left.isEqual(right) + nl + '差: ' + left.sub(right) + nl + nl; a = new Complex(Math.floor(Math.random() * 100), Math.floor(Math.random() * 100)); b = new Complex(0.6, 0.8); left = a.sub(b).abs(); right = one.sub(a.conjugate().mul(b)).abs(); output1 += 'a = ' + a + ', b = ' + b + nl + '左辺 = 右辺: ' + left.isEqual(right) + nl + '差: ' + left.sub(right) + nl; div_output.innerHTML = output0 + output1; }; calc(); button_calc.onclick = calc; }());