2017年5月15日月曜日

学習環境

数学読本〈4〉数列の極限,順列/順列・組合せ/確率/関数の極限と微分法(松坂 和夫(著)、岩波書店)の第17章(関数の変化をとらえる - 関数の極限と微分法)、17.1(関数と極限)、極限の応用問題、問12.を取り組んでみる。


  1. u3=4v v=u+7 y= 4 3 x+4 y= u+7 u xu+7 4 3 x+4= u7 u xu+7 x= u3 u7 u + 4 3 = u3 3u21+4u 3u = 3u( u3 ) 7u21 = 3u( u3 ) 7( u3 ) = 3u 7 y= 4 3 · 3u 7 +4 = 4u 7 +4 = 284u 7 lim u3+ 3u 7 = 9 7 lim u3+ 284u 7 = 16 7 R( 9 7 , 16 7 )

コード(Emacs)

Python 3

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from sympy import Symbol, symbols, solve, Limit, pprint

u, v, x, y = symbols('u v x y', positive=True)

expr1 = (u - 3) - (4 - v)
expr2 = -4 / 3 * x + 4 - y
expr3 = - v / u * x + v - y
s = solve((expr1, expr2, expr3), x, y, v, dict=True)[0]
print(s)
rx = s[x]
ry = s[y]
pprint(Limit(rx, u, 3, dir='+').doit() - 9 / 7)
pprint(Limit(ry, u, 3, dir='+').doit() - 16 / 7)

入出力結果(Terminal, IPython)

$ ./sample12.py
{x: 0.428571428571429*u, y: -0.571428571428571*u + 4.0, v: -u + 7.0}
-2.22044604925031e-16
0
$

コード(Emacs)

HTML5

<div id="graph0"></div>
<pre id="output0"></pre>
<label for="u0">u = </label>
<input id="u0" type="number" min="3.01" step="0.01" value="5">
v = <span id="v0"></span>
<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="sample12.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_u = document.querySelector('#u0'),
    inputs = [input_u],
    span_v = document.querySelector('#v0'),
    p = (x) => pre0.textContent += x + '\n';

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

    let u = parseFloat(input_u.value),
        v = -u + 7;

    if (u === 3) {
        return;
    }
    let f = (n) => Math.cos(theta / 2 ** n),
        lines = [[3, 0, 0, 4],
                 [u, 0, 0, v],
                 [9 / 7, 0, 9 / 7, 5],
                 [0, 16 / 7, 5, 16 / 7]];
    
    let xscale = d3.scaleLinear()
        .domain([0, 5])
        .range([padding, width - padding]);
    let yscale = d3.scaleLinear()
        .domain([0, 5])
        .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(lines)
        .enter()
        .append('line')
        .attr('x1', (d) => xscale(d[0]))
        .attr('y1', (d) => yscale(d[1]))
        .attr('x2', (d) => xscale(d[2]))
        .attr('y2', (d) => yscale(d[3]))
        .attr('stroke', (d, i) =>
              i === 0 ? 'green' :
              i === 1 ? 'blue' : 'lightgray');
    
    svg.append('g')
        .attr('transform', `translate(0, ${yscale(0)})`)
        .call(xaxis);

    svg.append('g')
        .attr('transform', `translate(${xscale(0)}, 0)`)
        .call(yaxis);
    span_v.textContent = v;
    p(`(${9 / 7}, ${16 / 7})`);
}

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



v = 













 
						

0 コメント:

コメントを投稿

Comments on Google+: