学習環境
- Surface 3 (4G LTE)、Surface 3 タイプ カバー、Surface ペン(端末)
- Windows 10 Pro (OS)
- 数式入力ソフト(TeX, MathML): MathType
- MathML対応ブラウザ: Firefox、Safari
- MathML非対応ブラウザ(Internet Explorer, Microsoft Edge, Google Chrome...)用JavaScript Library: MathJax
- 参考書籍
オイラーの贈物―人類の至宝eiπ=-1を学ぶ (吉田 武(著)、東海大学出版会)の第II部(関数の定義(Definitions of Functions))、第7章(三角関数(Trigonometric Function))、7.4(三角比の値を求める)、正多角形と三角比.を取り組んでみる。
コード(Emacs)
HTML5
<pre id="output0"></pre> <label for="n0">N = </label> <input id="n0" type="number" min="0" step="1" value="5"> <button id="run0">run</button> <button id="clear0">clear</button> <script src="sample0.js"></script>
JavaScript
let pre0 = document.querySelector('#output0'),
btn0 = document.querySelector('#run0'),
btn1 = document.querySelector('#clear0'),
input_n0 = document.querySelector('#n0'),
inputs = [input_n0],
p = (x) => pre0.textContent += x + '\n',
range = (start, end, step=1) => {
let res = [];
for (let i = start; i < end; i += step) {
res.push(i);
}
return res;
};
let output = () => {
let n0 = parseInt(input_n0.value, 10);
p(`正${n0}角形: ${2 * n0 * Math.sin(Math.PI / n0)}`);
p(`2π: ${2 * Math.PI}`);
};
inputs.forEach((input) => input.onchange = output);
btn0.onclick = output;
btn1.onclick = () => pre0.textContent = '';
output();
0 コメント:
コメントを投稿