math-matrix-operation.html
* created: 2025-06-02T23:16
* modified: 2025-06-05T22:43
title
Matrix operation
description
You can do math with the matrix.
Arithmetic with matrices
Multiplying matrices
Multiplying a matrix is only then possible if the one matrix has as many rows as the other columns.
We always multiply each element of each row of the first matrix by each element of each column of the subsequent matrix.
TODO! Illustrate these steps.
Let's go with an example. We define:
A :=
\begin{bmatrix}
1 & -1 & 2 \\
-2 & 0 & 6
\end{bmatrix}
, \;
B :=
\begin{bmatrix}
1 & -2 \\
4 & 5 \\
-3 & 7
\end{bmatrix}
\; \text{and} \;
C :=
\begin{bmatrix}
9 \\
4 \\
7
\end{bmatrix}
Now let look at how we would A \cdot B: $$
\begin{bmatrix}
1 \cdot 1 + -1 \cdot 4 + 2 \cdot -3 & 1 \cdot -2 + -1 \cdot 5 + 2 \cdot 7 \
-2 \cdot 1 + 0 \cdot 4 + 6 \cdot -3 & -2 \cdot -2 + 0 \cdot 5 + 6 \cdot 7
\end{bmatrix}
\begin{bmatrix}
2 & -7 \
16 & 46
\end{bmatrix}
$$
The resulting matrix is in 2\times2 dimensions.
We could also look at B \cdot A: $$
\begin{bmatrix}
1 \cdot 1 + -2 \cdot -2 & 1 \cdot -1 + -2 \cdot 0 & 1 \cdot 2 + -2 \cdot 6 \
4 \cdot 1 + 5 \cdot -2 & 4 \cdot -1 + 5 \cdot 0 & 4 \cdot 2 + 5 \cdot 6 \
-3 \cdot 1 + 7 \cdot -2 & -3 \cdot -1 + 0 \cdot 7 & -3 \cdot 2 + 7 \cdot 6 \
\end{bmatrix}
\begin{bmatrix}
5 & -1 & -10 \
-6 & -4 & 38 \
-17 & 3 & 36
\end{bmatrix}
$$
The resulting matrix is in 3 \times 3 dimensions.