MatrixSymbol
s#
Show code cell content
import sympy as sp
from IPython.display import display
Here are some examples of computations with MatrixSymbol
.
\[\displaystyle K\]
\[\displaystyle K_{i, j}\]
\[\displaystyle K_{0, 0}\]
\[\displaystyle \sum_{i_{1}=0}^{n - 1} A_{0, i_{1}} K_{i_{1}, 0}\]
The important thing is that elements of a MatrixSymbol
can be substituted:
Now make the matrices \(2 \times 2\) by specifying \(n\):
(A_n2 * K_n2)[0, 0]
\[\displaystyle A_{0, 0} K_{0, 0} + A_{0, 1} K_{1, 0}\]
v, w, x, y = sp.symbols("v, w, x, y", real=True)
substitutions = {
A_n2[0, 0]: v,
A_n2[0, 1]: w,
K_n2[0, 0]: x,
K_n2[1, 0]: y,
}
(A_n2 * K_n2)[0, 0].subs(substitutions)
\[\displaystyle v x + w y\]