学習環境
- 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
- 参考書籍
集合・位相入門 (松坂 和夫(著)、岩波書店)の第1章(集合と写像)、2(集合間の演算)、問題8、9を取り組んでみる。
コード(Emacs)
Python 3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from matplotlib_venn import venn3
import matplotlib.pyplot as plt
from sympy import pprint, FiniteSet, Interval
print('8.')
phi = FiniteSet()
X = FiniteSet(*range(7))
A = FiniteSet(*range(5))
B = FiniteSet(*range(1, 6))
XS = [(A, phi, A),
(A, X, A.complement(X)),
(A, A, phi),
(A, A.complement(X), X)]
for X0 in [phi, X, A, B]:
pprint(X0)
for i, (A0, B0, C0) in enumerate(XS):
print(f'({chr(ord("a") + i)})')
for X0 in [A0, B0, A0.symmetric_difference(B0), C0]:
pprint(X0)
print(A0.symmetric_difference(B0) == C0)
print()
venn3(subsets=(X, A, B), set_labels=('X', 'A', 'C'))
plt.savefig('sample8.svg')
入出力結果(Terminal, Jupyter(IPython))
$ ./sample8.py
8.
∅
{0, 1, 2, 3, 4, 5, 6}
{0, 1, 2, 3, 4}
{1, 2, 3, 4, 5}
(a)
{0, 1, 2, 3, 4}
∅
{0, 1, 2, 3, 4}
{0, 1, 2, 3, 4}
True
(b)
{0, 1, 2, 3, 4}
{0, 1, 2, 3, 4, 5, 6}
{5, 6}
{5, 6}
True
(c)
{0, 1, 2, 3, 4}
{0, 1, 2, 3, 4}
∅
∅
True
(d)
{0, 1, 2, 3, 4}
{5, 6}
{0, 1, 2, 3, 4, 5, 6}
{0, 1, 2, 3, 4, 5, 6}
True
$
0 コメント:
コメントを投稿