学習環境
- Surface 3 (4G LTE)、Surface 3 タイプ カバー、Surface ペン(端末)
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad Pro + Apple Pencil
- MyScript Nebo(iPad アプリ)
- 参考書籍
数学読本〈6〉線形写像・1次変換/数論へのプレリュード/集合論へのプレリュード/εとδ/落ち穂拾い など(松坂 和夫(著)、岩波書店)の第24章(無限をかぞえる - 集合論へのプレリュード)、24.2(可算集合)、可算集合の性質(2)、問2.を取り組んでみる。
任意の正の整数は、
という形に表される。
よって全射である。
また、
すなわち、
は一意的に定まる。
ゆえに単射である。
以上より、問題の写像 h は全単射である。
コード(Emacs)
Python 3
#!/usr/bin/env python3
def h(m, n):
return 2 ** (m - 1) * (2 * n - 1)
nums = {}
for m in range(1, 5):
for n in range(1, 5):
nums[h(m, n)] = f'h({m}, {n})'
for k in sorted(nums.keys()):
print(f'{nums[k]} = {k}')
入出力結果(Terminal, Jupyter(IPython))
$ ./sample2.py h(1, 1) = 1 h(2, 1) = 2 h(1, 2) = 3 h(3, 1) = 4 h(1, 3) = 5 h(2, 2) = 6 h(1, 4) = 7 h(4, 1) = 8 h(2, 3) = 10 h(3, 2) = 12 h(2, 4) = 14 h(3, 3) = 20 h(4, 2) = 24 h(3, 4) = 28 h(4, 3) = 40 h(4, 4) = 56 $
HTML5
<pre id="output0"></pre> <label for="m0">m = </label> <input id="m0" type="number" min="1" step="1" value="1"> <label for="n0">n = </label> <input id="n0" type="number" min="1" step="1" value="1"> <button id="run0">run</button> <button id="clear0">clear</button> <script src="sample2.js"></script>
JavaScript
let pre0 = document.querySelector('#output0'),
btn0 = document.querySelector('#run0'),
btn1 = document.querySelector('#clear0'),
input_m = document.querySelector('#m0'),
input_n = document.querySelector('#n0'),
inputs = [input_m, input_n],
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 h = (m, n) => 2 ** (m - 1) * (2 * n - 1);
let output = () => {
let m = parseInt(input_m.value, 10),
n = parseInt(input_n.value, 10);
p(`h(${m}, ${n}) = ${h(m, n)}`);
};
inputs.forEach((input) => input.onchange = output);
btn0.onclick = output;
btn1.onclick = () => pre0.textContent = '';
output();
0 コメント:
コメントを投稿