2016年9月1日木曜日

学習環境/開発環境

数学読本〈3〉平面上のベクトル/複素数と複素平面/空間図形/2次曲線/数列 (松坂 和夫(著)、岩波書店)の第10章(新しい数とその表示 - 複素数と複素平面)、10.1(複素平面)、複素数の絶対値、問2、3、4.を取り組んでみる。

問2.


  1. 2· 10 20 2 =40

  2. 5 13 2 ·5 = 130 10

問3.

| α+β | 2 + | αβ | 2 =( α+β ) ( α+β ) ¯ +( αβ ) ( αβ ) ¯ =( α+β )( α ¯ + β ¯ )+( αβ )( α ¯ β ¯ ) =α α ¯ +β β ¯ = | α | 2 + | β | 2

問4.

| αβ | 2 =( αβ ) ( αβ ) ¯ =( αβ )( α ¯ β ¯ ) = | α | 2 + | β | 2 2( α β ¯ + α ¯ β ) | 1 α ¯ β | 2 =( 1 α ¯ β )( 1α β ¯ ) =1+ | α | 2 | β | 2 2( α β ¯ + α ¯ β ) | α |=1 | α | 2 + | β | 2 =1+ | β | 2 1+ | α | 2 | β | 2 =1+ | β | 2 | β |=1 | α | 2 + | β | 2 = | α | 2 +1 1+ | α | 2 | β | 2 = | α | 2 +1

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) <math><mn>' + n + '</mn></math>' + 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) <math><mn>' + n + '</mn></math>' + 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;
}());

0 コメント:

コメントを投稿