学習環境
- 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(集合間の演算)、練習問題4を取り組んでみる。
コード(Emacs)
Python 3
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from matplotlib_venn import venn3_unweighted import matplotlib.pyplot as plt from sympy import pprint, FiniteSet, Interval print('4.') X = FiniteSet(*range(7)) A = FiniteSet(*range(5)) B = FiniteSet(*range(1, 6)) C = FiniteSet(*range(2, 7)) for X0 in [X, A, B, C]: pprint(X0) XS = [(A - (B | C), (A - B) & (A - C)), (A - (B & C), (A - B) | (A - C)), ((A | B) - C, (A - C) | (B - C)), ((A & B) - C, (A - C) & (B - C)), (A & (B - C), (A & B) - (A & C))] for i, (L, R) in enumerate(XS): print(f'({chr(ord("a") + i)})') for X in [L, R]: pprint(X) print(L == R) print() venn3_unweighted(subsets=(A, B, C)) plt.savefig('sample4.svg')
入出力結果(Terminal, Jupyter(IPython))
$ ./sample4.py 4. {0, 1, 2, 3, 4, 5, 6} {0, 1, 2, 3, 4} {1, 2, 3, 4, 5} {2, 3, 4, 5, 6} (a) {0} {0} True (b) {0, 1} {0, 1} True (c) {0, 1} {0, 1} True (d) {1} {1} True (e) {1} {1} True $
0 コメント:
コメントを投稿