学習環境/開発環境
- Surface 3 (4G LTE)、Surface 3 タイプ カバー、Surface ペン(端末)
- Windows 10 Pro (OS)
- 数式入力ソフト(TeX, MathML): MathType
- MathML対応ブラウザ: Firefox、Safari
- MathML非対応ブラウザ(Internet Explorer, Google Chrome...)用JavaScript Library: MathJax
- OS X El Capitan - Apple (OS)
- Emacs (Text Editor)
- JavaScript (プログラミング言語)
- kjs-math-number (JavaScript Library)
- Safari(Web browser)
線型代数入門 (松坂 和夫(著)、岩波書店)の第4章(複素数、複素ベクトル空間)、2(複素平面)、問6.を取り組んでみる。
問6.
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,
one = 1,
left,
right,
output = '';
a = new Complex(0.6, 0.8);
b = new Complex(Math.random(), Math.random());
left = a.sub(b).magnitude();
right = one.sub(a.conjugate().mul(b)).magnitude();
output +=
'a = <math>' + a + '</math>, b = <math>' + b + '</math>' + nl +
'左辺 = ' + left + ', 右辺 = ' + right + nl +
'左辺 = 右辺: ' + left.isEqual(right) + nl +
'差: 左辺 - 右辺 = ' + left.sub(right) + nl + nl;
a = new Complex(Math.random(), Math.random());
b = new Complex(0.8, 0.6);
left = a.sub(b).magnitude();
right = one.sub(a.conjugate().mul(b)).magnitude();
output +=
'a = <math>' + a + '</math>, b = <math>' + b + '</math>' + nl +
'左辺 = ' + left + ', 右辺 = ' + right + nl +
'左辺 = 右辺: ' + left.isEqual(right) + nl +
'差: 左辺 - 右辺 = ' + left.sub(right) + nl + nl;
div_output.innerHTML = output;
};
calc();
button_calc.onclick = calc;
}())
0 コメント:
コメントを投稿