学習環境
- Surface 3 (4G LTE)、Surface 3 タイプ カバー、Surface ペン(端末)
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad Pro + Apple Pencil
- MyScript Nebo(iPad アプリ)
- 参考書籍
ラング線形代数学(上)(S.ラング (著)、芹沢 正三 (翻訳)、ちくま学芸文庫)の7章(スカラー積と直交性)、3(一般の直交基底)、練習問題1-(a)、(b).を取り組んでみる。
コード(Emacs)
Python 3
#!/usr/bin/env python3
from sympy import pprint, symbols, Matrix
print('1.')
def spa(x, y):
return x[0] * y[0] + 2 * x[1] * y[1] + x[2] * y[2]
def spb(x, y):
return x[0] * y[0] - 3 * x[1] * y[1] + x[0] * y[2] - x[2] * y[1]
sps = [spa, spb]
ts = [(Matrix([[1, 1, 1]]), Matrix([[3, -5, 7]])),
(Matrix([[1, -1, 4]]), Matrix([[-1, 1, 2]]))]
for i, (sp, (a, b)) in enumerate(zip(sps, ts)):
print(f'({chr(ord("a") + i)})')
for t in [a, b, sp(a, b)]:
pprint(t)
print()
print()
入出力結果(Terminal, Jupyter(IPython))
$ ./sample1.py 1. (a) [1 1 1] [3 -5 7] 0 (b) [1 -1 4] [-1 1 2] 0 $
0 コメント:
コメントを投稿