学習環境
- 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(集合間の演算)、練習問題3を取り組んでみる。
コード(Emacs)
Python 3
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from matplotlib_venn import venn2 import matplotlib.pyplot as plt from sympy import pprint, FiniteSet, Interval print('3.') print('(a)') X = FiniteSet(*range(10)) A = FiniteSet(*range(5)) B = FiniteSet(*range(5, 10)) X1 = A - B X2 = (A | B) - B X3 = A - (A & B) X4 = A & B.complement(X) for X in [A, B, X1, X2, X3, X4]: pprint(X) print(X1 == X2 == X3 == X4) venn2(subsets=(A, B)) plt.savefig('sample3_a.svg') print('(b)') A = Interval.open(0, 1) B = Interval.open(1, 2) for X in [A, B]: pprint(X) print(A - B == A) print(A & B == FiniteSet()) print('(c)') A = FiniteSet(*range(5)) B = FiniteSet(*range(10)) pprint(A - B) print(A.is_subset(B)) print(B.is_superset(A)) venn2(subsets=(A, B)) plt.savefig('sample3_c.svg')
入出力結果(Terminal, Jupyter(IPython))
$ ./sample3.py 3. (a) {0, 1, 2, 3, 4} {5, 6, 7, 8, 9} {0, 1, 2, 3, 4} {0, 1, 2, 3, 4} {0, 1, 2, 3, 4} {0, 1, 2, 3, 4} True (b) (0, 1) (1, 2) True True (c) ∅ True True $
0 コメント:
コメントを投稿