I am Charmie

メモとログ

sympy

Sympyまとめ (N-dim array)

Sympyのtensor用機能 We have two tensors $latex A \in \mathbb{R}^{I_1 \times \ldots \times I_N}$ and $latex B \in \mathbb{R}^{J_1 \times \ldots \times J_N}$. An element is specified by $latex A(i_1, \ldots, i_N)$, where $latex 1 \leq i_k \l…

Sympyまとめ (Matrices)

[code lang="python"] >>> Matrix([[1, -1], [3, 4], [0, 2]]) ⎡1 -1⎤ ⎢ ⎥ ⎢3 4 ⎥ ⎢ ⎥ ⎣0 2 ⎦ 列ベクトルを作るには,要素のリストを与える >>> Matrix([1, 2, 3]) ⎡1⎤ ⎢ ⎥ ⎢2⎥ ⎢ ⎥ ⎣3⎦ 行列とベクトルの掛け算 >>> M = Matrix([[1, 2, 3], [3, 2, 1]]) >>> …

SymPyまとめ (simplification)

From basic operations, 1.1. evalf() outputs numerical value(s). [code lang="python"] >>> expr = sqrt(8) >>> expr 2 * sqrt(2) >>> expr.evalf() 2.82842712474619 [/code] 1.2. lambdify acts like lambda function. [code lang="python"] >>> import…