Rudolf Adamkovič Personal site


Example

Compute by hand:

\[\begin{flalign*}
  \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}
  \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix}
  & =
  \begin{pmatrix}
    \vphantom{\Bigg(}
    \negthickspace
    \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}
    \begin{pmatrix} 5 \\ 7 \end{pmatrix}
    &
    \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}
    \begin{pmatrix} 6 \\ 8 \end{pmatrix}
    \negthickspace
  \end{pmatrix}
  \\ & =
  \begin{pmatrix}
    \negthickspace
    \vphantom{\Bigg(}
    5 \begin{pmatrix} 1 \\ 3 \end{pmatrix}
    + 7 \begin{pmatrix} 2 \\ 4 \end{pmatrix}
    &
    6 \begin{pmatrix} 1 \\ 3 \end{pmatrix}
    + 8 \begin{pmatrix} 2 \\ 4 \end{pmatrix}
   \negthickspace
  \end{pmatrix}
  \\ & =
  \begin{pmatrix}
    \negthickspace
    \vphantom{\Bigg(}
    \begin{pmatrix} 5 \\ 15 \end{pmatrix}
    + \begin{pmatrix} 14 \\ 28 \end{pmatrix}
    &
    \begin{pmatrix} 6 \\ 18 \end{pmatrix}
    + \begin{pmatrix} 16 \\ 32 \end{pmatrix}
    \negthickspace
  \end{pmatrix}
  \\ & =
  \begin{pmatrix}
    19 & 22 \\
    43 & 50
  \end{pmatrix}. &
\end{flalign*}
\]

Compute with NumPy:

import numpy

a = numpy.array([[1, 2],
                 [3, 4]])

b = numpy.array([[5, 6],
                 [7, 8]])

a @ b

© 2024 Rudolf Adamkovič under GNU General Public License version 3.
Made with Emacs and the secret alien technologies of yesteryear.