学習環境
- Surface 3 (4G LTE)、Surface 3 タイプ カバー、Surface ペン(端末)
- Windows 10 Pro (OS)
- 数式入力ソフト(TeX, MathML): MathType
- MathML対応ブラウザ: Firefox、Safari
- MathML非対応ブラウザ(Internet Explorer, Google Chrome...)用JavaScript Library: MathJax
- 参考書籍
ラング線形代数学(上)(S.ラング (著)、芹沢 正三 (翻訳)、ちくま学芸文庫)の4章(線形写像)、1(写像)、練習問題1-7.を取り組んでみる。
コード(Emacs)
Python 3
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from sympy import pprint, symbols, sin, exp, log, cos, Derivative, Integral, Matrix print('1.') x = symbols('x') for i, f in enumerate([sin, exp, log]): print('({0})'.format(chr(ord('a') + i))) g = Derivative(f(x), x, 1) pprint(g) pprint(g.doit()) print() print('2.') t = symbols('t') for i, f in enumerate([exp(t), 1 / (1 + t ** 2), cos(t)]): print('({0})'.format(chr(ord('a') + i))) g = Integral(f, (t, 0, x)) pprint(g) pprint(g.doit()) print() print('3.') A = Matrix([[2, 3, -1]]) for i, x in enumerate([[1, 2, -3], [-1, 5, 0], [2, 1, 1]]): print('({0})'.format(chr(ord('a') + i))) print(A.dot(x)) print() print('4.') ft = Matrix([[exp(t), t]]) for i, t0 in enumerate([1, 0, -1]): print('({0})'.format(chr(ord('a') + i))) pprint(ft.subs({t: t0})) print() print('5.') gt = Matrix([[t, 2 * t]]) for i, t0 in enumerate([1, 2, 0]): print('({0})'.format(chr(ord('a') + i))) pprint((ft + gt).subs({t: t0})) print() print('7.') A = [1, 1, -1, 3] for i, x0 in enumerate([(1, 1, 0, -1), (2, 3, -1, 1)]): print('({0})'.format(chr(ord('a') + i))) X = Matrix([x0]) print(X.dot(A) + 2)
入出力結果(Terminal, IPython)
$ ./sample1.py 1. (a) d ──(sin(x)) dx cos(x) (b) d ⎛ x⎞ ──⎝ℯ ⎠ dx x ℯ (c) d ──(log(x)) dx 1 ─ x 2. (a) x ⌠ ⎮ t ⎮ ℯ dt ⌡ 0 x ℯ - 1 (b) x ⌠ ⎮ 1 ⎮ ────── dt ⎮ 2 ⎮ t + 1 ⌡ 0 atan(x) (c) x ⌠ ⎮ cos(t) dt ⌡ 0 sin(x) 3. (a) 11 (b) 13 (c) 6 4. (a) [ℯ 1] (b) [1 0] (c) ⎡ -1 ⎤ ⎣ℯ -1⎦ 5. (a) [1 + ℯ 3] (b) ⎡ 2 ⎤ ⎣2 + ℯ 6⎦ (c) [1 0] 7. (a) 1 (b) 11 $
0 コメント:
コメントを投稿