2017年5月9日火曜日

学習環境

解析入門〈1〉(松坂 和夫(著)、岩波書店)の第5章(各種の初等関数)、5.3(三角関数)、問題5.8、9.を取り組んでみる。


  1. A+B+C=π ABC A π 3 tanA 3 tanA=1 A= π 4 B+C=π π 4 = 3 4 π tan( B+C )=1 tan( B+C )= tanB+tanC 1tanBtanC tanB+tanC=tanBtanC1 tanBtanCtanBtanC1=0 ( tanB1 )( tanC1 )11=0 ( tanB1 )( tanC1 )=2 tanB1=1 tanC1=2 tanB=2 tanC=3

  2. tanα= a x tanβ= b x θ=αβ tanθ=tan( αβ ) = tanαtanβ 1+tanαtanβ = ab x 1+ ab x 2 = ( ab )x x 2 +ab ( x 2 +ab )2 x 2 ( x 2 +ab ) 4 = ab x 2 ( x 2 +ab ) 4 x= ab

コード(Emacs)

HTML5

<div id="graph0"></div>
<pre id="output0"></pre>
<label for="a0">a = </label>
<input id="a0" type="number" min="0.001" value="10">
<label for="b0">b = </label>
<input id="b0" type="number" min="0.001" value="5">
<label for="x0">x = </label>
<input id="x0" type="number" min="0.001" value="5">

<button id="draw0">draw</button>
<button id="clear0">clear</button>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.6/d3.min.js" integrity="sha256-5idA201uSwHAROtCops7codXJ0vja+6wbBrZdQ6ETQc=" crossorigin="anonymous"></script>

<script src="sample10.js"></script>    

JavaScript

let div0 = document.querySelector('#graph0'),
    pre0 = document.querySelector('#output0'),
    width = 600,
    height = 600,
    padding = 50,
    btn0 = document.querySelector('#draw0'),
    btn1 = document.querySelector('#clear0'),
    input_a0 = document.querySelector('#a0'),
    input_b0 = document.querySelector('#b0'),
    input_x0 = document.querySelector('#x0'),
    inputs = [input_a0, input_b0, input_x0],
    p = (x) => pre0.textContent += x + '\n';

let f = (a, b, x) => Math.atan((a - b) * x / (x **  2 + a * b));

let draw = () => {
    pre0.textContent = '';

    let a = parseFloat(input_a0.value),
        b = parseFloat(input_b0.value),
        x = parseFloat(input_x0.value);

    if (b <= 0 || a <= b || x <= 0) {
        return;
    }

    let points = [[0, a], [0, b]];

    let d = Math.max(a, x);
    let xscale = d3.scaleLinear()
        .domain([0, d])
        .range([padding, width - padding]);
    let yscale = d3.scaleLinear()
        .domain([0, d])
        .range([height - padding, padding]);

    let xaxis = d3.axisBottom().scale(xscale);
    let yaxis = d3.axisLeft().scale(yscale);
    div0.innerHTML = '';
    let svg = d3.select('#graph0')
        .append('svg')
        .attr('width', width)
        .attr('height', height);

    svg.selectAll('line')
        .data(points)
        .enter()
        .append('line')
        .attr('x1', (d) => xscale(d[0]))
        .attr('y1', (d) => yscale(d[1]))
        .attr('x2', xscale(x))
        .attr('y2', yscale(0))
        .attr('stroke', (d, i) => i === 0 ? 'green' : 'blue');

    svg.append('g')
        .attr('transform', `translate(0, ${yscale(0)})`)
        .call(xaxis);

    svg.append('g')
        .attr('transform', `translate(${xscale(0)}, 0)`)
        .call(yaxis);

    p(= ${f(a, b, x)}`);
}

inputs.forEach((input) => input.onchange = draw);
btn0.onclick = draw;
btn1.onclick = () => pre0.textContent = '';
draw();





















 
						

0 コメント:

コメントを投稿

Comments on Google+: