2017年5月16日火曜日

学習環境

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


  1. u 2 v 2 =1 y= v u1 ( x1 ) x= v u1 ( x1 ) x= v u1 1 v u1 = v u1v = v v+1u R( v v+1u , v v+1u ) | QR | 2 = ( v v+1u u ) 2 + ( v v+1u v ) 2 = ( vuv+ u 2 u ) 2 + ( v v 2 +uvv ) 2 ( vu+1 ) 2 = ( u 2 ( v+1 )u+v ) 2 + ( ( uv )v ) 2 ( vu+1 ) 2 = ( ( uv )( u1 ) ) 2 + ( ( uv )v ) 2 ( vu+1 ) 2 = ( uv ) 2 ( ( u1 ) 2 + v 2 ) ( vu+1 ) 2 = ( uv ) 2 ( ( u1 ) 2 + u 2 1 ) ( vu+1 ) 2 = ( uv ) 2 2u( u1 ) ( vu+( u 2 v 2 ) ) 2 = ( uv ) 2 2u( u1 ) ( ( uv )+( uv )( u+v ) ) 2 = 2u( u1 ) ( u+v1 ) 2 = 2u( u1 ) ( u+ u 2 1 1 ) 2 lim u 2u( u1 ) ( u+ u 2 1 1 ) 2 = lim u 2( 1 1 u ) ( 1+ 1 1 u 2 1 u ) 2 = 2 4 = 1 2 lim u | QR |= 1 2

コード(Emacs)

Python 3

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

from sympy import symbols, solve, sqrt, Limit, pprint, S

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

exprs = (
    u ** 2 - v ** 2 - 1,
    v / (u - 1) * (x - 1) - y,
    v / (u - 1) * (x - 1) - x
)

s = solve(exprs, x, y, v, dict=True)
pprint(s)

s = s[1]
rx = s[x]
ry = s[y]
v = s[v]

qr = sqrt((rx - u) ** 2 + (ry - v) ** 2)
pprint(qr)

pprint(Limit(qr, u, S.Infinity).doit())

入出力結果(Terminal, IPython)

$ ./sample13.py
⎡⎧                           ________                ________    ⎫  ⎧          
⎢⎪       ________           ╱  2                    ╱  2         ⎪  ⎪      ____
⎢⎨      ╱  2          u   ╲╱  u  - 1    1     u   ╲╱  u  - 1    1⎬  ⎨     ╱  2 
⎢⎪v: -╲╱  u  - 1 , x: ─ - ─────────── + ─, y: ─ - ─────────── + ─⎪, ⎪v: ╲╱  u  
⎣⎩                    2        2        2     2        2        2⎭  ⎩          

                ________                ________    ⎫⎤
____           ╱  2                    ╱  2         ⎪⎥
         u   ╲╱  u  - 1    1     u   ╲╱  u  - 1    1⎬⎥
- 1 , x: ─ + ─────────── + ─, y: ─ + ─────────── + ─⎪⎥
         2        2        2     2        2        2⎭⎦
       ___________________________________________________
      ╱                        2                        2 
     ╱  ⎛         ________    ⎞    ⎛       ________    ⎞  
    ╱   ⎜        ╱  2         ⎟    ⎜      ╱  2         ⎟  
   ╱    ⎜  u   ╲╱  u  - 1    1⎟    ⎜u   ╲╱  u  - 1    1⎟  
  ╱     ⎜- ─ + ─────────── + ─⎟  + ⎜─ - ─────────── + ─⎟  
╲╱      ⎝  2        2        2⎠    ⎝2        2        2⎠  
√2
──
2
$

コード(Emacs)

HTML5

<div id="graph0"></div>
<pre id="output0"></pre>
<label for="dx">d = </label>
<input id="dx" type="number" min="0" value="0.001">
<label for="x1">x1 = </label>
<input id="x1" type="number" min="0.001" value="0">
<label for="x2">x2 = </label>
<input id="x2" type="number" min="0" value="5">
<label for="r0">r = </label>
<input id="r0" type="number" min="0" value="0.5">
<br>
<label for="u0">u = </label>
<input id="u0" type="number" min="1.01" step="0.01" value="2">
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="sample13.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_dx = document.querySelector('#dx'),
    input_x1 = document.querySelector('#x1'),
    input_x2 = document.querySelector('#x2'),
    input_r = document.querySelector('#r0'),
    input_u = document.querySelector('#u0'),
    inputs = [input_dx, input_x1, input_x2, input_r, input_u],
    span_v = document.querySelector('#v0'),
    p = (x) => pre0.textContent += x + '\n';

let f = (x) => Math.sqrt(x ** 2 - 1);

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

    let dx = parseFloat(input_dx.value),
        x1 = parseFloat(input_x1.value),
        x2 = parseFloat(input_x2.value),
        r = parseFloat(input_r.value),
        u = parseFloat(input_u.value);

    if (dx === 0 || x1 >= x2|| r <= 0 || u <= 1) {
        return;
    }
    let v = Math.sqrt(u ** 2 - 1),
        f0 = (x) => v / (u - 1) * (x - 1);

    span_v.textContent = v;

    let points = [];
    
    for (let x = Math.max(1, x1); x <= x2; x += dx) {
        points.push([x, f(x)]);
    }

    console.log(points);
    
    let lines = [[x1, x1, x2, x2],
                 [1, 0, x2, f0(x2)]];
    
    let xscale = d3.scaleLinear()
        .domain([x1, x2])
        .range([padding, width - padding]);
    let yscale = d3.scaleLinear()
        .domain([x1, x2])
        .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 ? 'red' : 'green');

    svg.selectAll('circle')
        .data(points)
        .enter()
        .append('circle')
        .attr('cx', (d) => xscale(d[0]))
        .attr('cy', (d) => yscale(d[1]))
        .attr('r', r)
        .attr('fill', 'blue');
    
    svg.append('g')
        .attr('transform', `translate(0, ${height - padding})`)
        .call(xaxis);

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

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










v =

0 コメント:

コメントを投稿