## 2017年4月20日木曜日

### 数学 - JavaScript - 解析学 - 各種の初等関数 - 対数関数・指数関数(一般の対数関数、指数関数、極限)

1. $\begin{array}{l}\underset{h\to 0}{\mathrm{lim}}\frac{\mathrm{log}\left(1+h\right)}{h\mathrm{log}a}\\ =\underset{h\to 0}{\mathrm{lim}}\frac{\mathrm{log}{\left(1+h\right)}^{\frac{1}{h}}}{\mathrm{log}a}\\ =\frac{1}{\mathrm{log}a}\end{array}$

2. $\underset{h\to 0}{\mathrm{lim}}\frac{{a}^{0+h}-{a}^{0}}{h}={a}^{0}\mathrm{log}a=\mathrm{log}a$

コード(Emacs)

HTML5

<div id="graph0"></div>
<pre id="output0"></pre>
a = <input id="a0" type="number" min="0.01" step="0.01" value="2">
<br>
<button id="draw0">draw</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'),
input0 = document.querySelector('#a0'),
pre0 = document.querySelector('#output0'),
width = 600,
height = 600,
btn0 = document.querySelector('#draw0'),
p = (x) => pre0.textContent = x + '\n'
f = (a, h) => Math.log(1 + h) / (h * Math.log(a)),
g = (a, h) => (Math.pow(a, h) - 1) / h,
h1 = (a) => Math.log(a),
h2 = (a) => 1 / h1(a);

let draw = () => {
let points = [],
a = parseFloat(input0.value);

if (a === 1) {
return;
}
for (let h = -0.99; h < 1; h += 0.001) {
if (h === 0) {
continue;
}
points.push([h, f(a, h)]);
}
for (let h = -0.99; h < 1; h += 0.001) {
if (h === 0) {
continue;
}
points.push([h, g(a, h)]);
}
for (let h = -0.99; h < 1; h += 0.001) {
if (h === 0) {
continue;
}
points.push([h, h1(a)]);
}
for (let h = -0.99; h < 1; h += 0.001) {
if (h === 0) {
continue;
}
points.push([h, h2(a)]);
}
let xscale = d3.scaleLinear()
.domain([-1, 1])
let ys = points.map((a) => a[1]);
let yscale = d3.scaleLinear()
.domain([Math.min(...ys), Math.max(...ys)])

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);

let t1 = points.length / 4,
t2 = 2 * points.length / 4,
t3 = 3 * points.length / 4;
svg.selectAll('circle')
.data(points)
.enter()
.append('circle')
.attr('cx', (d) => xscale(d[0]))
.attr('cy', (d) => yscale(d[1]))
.attr('r', 1)
.attr('fill', (d, i) =>
i < t1 ? 'green' :
i < t2 ? 'blue' :
i < t3 ? 'red' : 'red');

svg.append('g')
.attr('transform', translate(0, ${height - padding})) .call(xaxis); svg.append('g') .attr('transform', translate(${padding}, 0))
.call(yaxis);
p(log ${a} =${h1(a)});
}

input0.onchange = draw;
btn0.onclick = draw;

draw();


a =