学習環境
- Surface
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
解析入門(中) (松坂和夫 数学入門シリーズ 5) (松坂 和夫(著)、岩波書店)の第11章(集合論初歩)、11.2(濃度)、問題9の解答を求めてみる。
よって、 求める全単射 F は
コード
#!/usr/bin/env python3
from sympy import Rational
import matplotlib.pyplot as plt
print('9.')
n = 5
def frange(start, stop, step=0.05):
result = []
while start < stop:
result.append(start)
start += step
return result
def f(x):
if x in [Rational(1, k) for k in range(1, n + 1)]:
return x
return x / (1 - x)
xs = frange(0, Rational(1, n)) + [Rational(1, n)]
for k in range(n - 1):
xs += frange(Rational(1, 5 - k) + 0.001,
Rational(1, 5 - k - 1)) + \
[Rational(1, 5 - k - 1)]
ys = [f(x) for x in xs]
for x, y in zip(xs, ys):
print((x, y))
plt.plot(xs, ys)
plt.savefig('sample9.png')
入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))
% ./sample9.py
9.
(0, 0.0)
(0.05, 0.052631578947368425)
(0.1, 0.11111111111111112)
(0.15000000000000002, 0.17647058823529416)
(1/5, 1/5)
(0.201000000000000, 0.251564455569462)
(1/4, 1/4)
(0.251000000000000, 0.335113484646195)
(0.301000000000000, 0.430615164520744)
(1/3, 1/3)
(0.334333333333333, 0.502253380070105)
(0.384333333333333, 0.624255549539794)
(0.434333333333333, 0.767825574543312)
(0.484333333333333, 0.939237233354880)
(1/2, 1/2)
(0.501000000000000, 1.00400801603206)
(0.551000000000000, 1.22717149220490)
(0.601000000000000, 1.50626566416040)
(0.651000000000000, 1.86532951289398)
(0.701000000000000, 2.34448160535117)
(0.751000000000000, 3.01606425702812)
(0.801000000000000, 4.02512562814071)
(0.851000000000000, 5.71140939597317)
(0.901000000000000, 9.10101010101014)
(0.951000000000000, 19.4081632653063)
(1, 1)
%
0 コメント:
コメントを投稿