The Ultimate Step-by-Step Guide to Basic Matrix Operations for Beginners


The Ultimate Step-by-Step Guide to Basic Matrix Operations for Beginners

Matrices are one of the most powerful tools in mathematics. In this step-by-step guide to basic matrix operations, you’ll learn how to perform operations such as matrix addition, matrix subtraction, matrix multiplication, scalar multiplication, transpose, and trace.

This guide explains each operation with step-by-step examples. By the end, you’ll know how to perform these calculations and understand why they work, giving you a strong foundation for more advanced topics in linear algebra.

The following infographic illustrates the concepts covered in this article.

Matrix Operations Infographic Resized. Related Article - The Ultimate Step-by-Step Guide to Basic Matrix Operations for Beginners.

What Is a Matrix?

A matrix is a rectangular array of numbers arranged in rows and columns. Each number inside the matrix is called an entry, and its position is identified by its row and column.

For example, a matrix with two rows and three columns is called a 2×3 matrix. The general form looks like

$$\begin{bmatrix}
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23}
\end{bmatrix}$$

Here, \( a_{11} \) is the element in the first row and first column, while \( a_{23} \) is in the second row and third column. The notation \( m \times n \) indicates that the matrix has \( m \) rows and \( n \) columns.

Matrices come in different types, depending on their shape and properties:

Row matrix: A matrix with only one row.

Column matrix: A matrix with only one column.

Square matrix: A matrix with the same number of rows and columns.

Zero matrix: A matrix in which all entries are zero.

Diagonal matrix: A square matrix where all non-diagonal entries are zero.

Identity matrix: A diagonal matrix where all diagonal entries are one.

Matrix Addition

Matrix addition is performed by adding the corresponding entries of two matrices with the same number of rows and columns.

Example 1: Evaluate:
(a) $$\begin{bmatrix}
2 & -1 & 3 \\
4 & 0 & 5 \\
1 & 2 & -2
\end{bmatrix}
+
\begin{bmatrix}
3 & 4 & 1 \\
-2 & 1 & 0 \\
5 & -1 & 2
\end{bmatrix}$$
(b) $$\begin{bmatrix}
1 & 0 & 2 \\
-3 & 4 & 1
\end{bmatrix}
+
\begin{bmatrix}
2 & 3 & -1 \\
0 & 1 & 5
\end{bmatrix}$$

Solution: (a) $$\begin{bmatrix}
2 & -1 & 3 \\
4 & 0 & 5 \\
1 & 2 & -2
\end{bmatrix}
+
\begin{bmatrix}
3 & 4 & 1 \\
-2 & 1 & 0 \\
5 & -1 & 2
\end{bmatrix}$$

Adding corresponding entries, we get

$$\begin{bmatrix}
2 + 3 & -1 + 4 & 3 + 1 \\
4 – 2 & 0 + 1 & 5 + 0 \\
1 + 5 & 2 – 1 & -2 + 2
\end{bmatrix}.$$

Adding and subtracting, we arrive at a final answer of

$$\begin{bmatrix}
5 & 3 & 4 \\
2 & 1 & 5 \\
6 & 1 & 0
\end{bmatrix}.$$

(b) $$\begin{bmatrix}
1 & 0 & 2 \\
-3 & 4 & 1
\end{bmatrix}
+
\begin{bmatrix}
2 & 3 & -1 \\
0 & 1 & 5
\end{bmatrix}$$

Adding corresponding entries, we get

$$\begin{bmatrix}
1 + 2 & 0 + 3 & 2 – 1 \\
-3 + 0 & 4 + 1 & 1 + 5
\end{bmatrix}.$$

Adding and subtracting, we arrive at a final answer of

$$\begin{bmatrix}
3 & 3 & 1 \\
-3 & 5 & 6
\end{bmatrix}.$$

Matrix Subtraction

Matrix subtraction works like addition; each entry in the first matrix is reduced by the corresponding entry in the second matrix. Again, both matrices must have the same number of rows and columns.

Example 2: Evaluate:
(a) $$\begin{bmatrix}
3 & 4 & 1 \\
-2 & 1 & 0 \\
5 & -1 & 2
\end{bmatrix}

\begin{bmatrix}
2 & -1 & 3 \\
4 & 0 & 5 \\
1 & 2 & -2
\end{bmatrix}$$
(b) $$\begin{bmatrix}
4 & 2 & 1 \\
-1 & 3 & 0
\end{bmatrix}

\begin{bmatrix}
1 & 5 & 0 \\
2 & 0 & 1
\end{bmatrix}$$

Solution: (a) $$\begin{bmatrix}
3 & 4 & 1 \\
-2 & 1 & 0 \\
5 & -1 & 2
\end{bmatrix}

\begin{bmatrix}
2 & -1 & 3 \\
4 & 0 & 5 \\
1 & 2 & -2
\end{bmatrix}$$

Subtracting corresponding entries, we get

$$\begin{bmatrix}
3 – 2 & 4 + 1 & 1 – 3 \\
-2 – 4 & 1 – 0 & 0 – 5 \\
5 – 1 & -1 – 2 & 2 + 2
\end{bmatrix}.$$

Adding and subtracting, we arrive at a final answer of

$$\begin{bmatrix}
1 & 5 & -2 \\
-6 & 1 & -5 \\
4 & -3 & 4
\end{bmatrix}.$$

(b) $$\begin{bmatrix}
4 & 2 & 1 \\
-1 & 3 & 0
\end{bmatrix}

\begin{bmatrix}
1 & 5 & 0 \\
2 & 0 & 1
\end{bmatrix}$$

Subtracting corresponding entries, we get

$$\begin{bmatrix}
4 – 1 & 2 – 5 & 1 – 0 \\
-1 – 2 & 3 – 0 & 0 – 1
\end{bmatrix}.$$

Subtracting, we arrive at a final answer of

$$\begin{bmatrix}
3 & -3 & 1 \\
-3 & 3 & -1
\end{bmatrix}.$$

Scalar Multiplication

Scalar multiplication involves multiplying every entry of a matrix by a number, which is called a scalar.

Example 3: Evaluate:
(a) $$2\begin{bmatrix}
2 & -1 & 3 \\
4 & 0 & 5 \\
1 & 2 & -2
\end{bmatrix}$$
(b) $$-3\begin{bmatrix}
1 & 2 & 3 \\
4 & -1 & 0
\end{bmatrix}$$

Solution: (a) $$2\begin{bmatrix}
2 & -1 & 3 \\
4 & 0 & 5 \\
1 & 2 & -2
\end{bmatrix}$$

Multiplying each entry by 2, we get

$$\begin{bmatrix}
2(2) & 2(-1) & 2(3) \\
2(4) & 2(0) & 2(5) \\
2(1) & 2(2) & 2(-2)
\end{bmatrix}.$$

Multiplying, we arrive at a final answer of

$$\begin{bmatrix}
4 & -2 & 6 \\
8 & 0 & 10 \\
2 & 4 & -4
\end{bmatrix}.$$

(b) $$-3\begin{bmatrix}
1 & 2 & 3 \\
4 & -1 & 0
\end{bmatrix}$$

Multiplying each entry by -3, we get

$$\begin{bmatrix}
-3(1) & -3(2) & -3(3) \\
-3(4) & -3(-1) & -3(0)
\end{bmatrix}.$$

Multiplying, we arrive at a final answer of

$$\begin{bmatrix}
-3 & -6 & -9 \\
-12 & 3 & 0
\end{bmatrix}.$$

Matrix Multiplication

Matrix multiplication is different from matrix addition and matrix subtraction. It is calculated by multiplying each row of the first matrix by each column of the second matrix. For the product to exist, the number of columns of the first matrix must equal the number of rows of the second matrix.

Example 4: Evaluate:
(a) $$\begin{bmatrix}
1 & 2 & 3 \\
0 & 1 & 4 \\
5 & 6 & 0
\end{bmatrix}
\begin{bmatrix}
-2 & 0 & 1 \\
3 & 5 & -1 \\
4 & 2 & 2
\end{bmatrix}$$
(b) $$\begin{bmatrix}
2 & 1 & 0 \\
-1 & 3 & 4
\end{bmatrix}
\begin{bmatrix}
1 & 2 \\
0 & -1 \\
3 & 0
\end{bmatrix}$$

Solution: (a) $$\begin{bmatrix}
1 & 2 & 3 \\
0 & 1 & 4 \\
5 & 6 & 0
\end{bmatrix}
\begin{bmatrix}
-2 & 0 & 1 \\
3 & 5 & -1 \\
4 & 2 & 2
\end{bmatrix}$$

Multiplying each row of the first matrix by each column of the second matrix, we get

$$\begin{bmatrix}
1(-2) + 2(3) + 3(4) & 1(0) + 2(5) + 3(2) & 1(1) + 2(-1) + 3(2) \\
0(-2) + 1(3) + 4(4) & 0(0) + 1(5) + 4(2) & 0(1) + 1(-1) + 4(2) \\
5(-2) + 6(3) + 0(4) & 5(0) + 6(5) + 0(2) & 5(1) + 6(-1) + 0(2)
\end{bmatrix}.$$

Multiplying we obtain

$$\begin{bmatrix}
-2 + 6 + 12 & 0 + 10 + 6 & 1 – 2 + 6 \\
0 + 3 + 16 & 0 + 5 + 8 & 0 – 1 + 8 \\
-10 + 18 + 0 & 0 + 30 + 0 & 5 – 6 + 0
\end{bmatrix}.$$

Adding and subtracting, we arrive at a final answer of

$$\begin{bmatrix}
16 & 16 & 5 \\
19 & 13 & 7 \\
8 & 30 & -1
\end{bmatrix}.$$

(b) $$\begin{bmatrix}
2 & 1 & 0 \\
-1 & 3 & 4
\end{bmatrix}
\begin{bmatrix}
1 & 2 \\
0 & -1 \\
3 & 0
\end{bmatrix}$$

Multiplying each row of the first matrix by each column of the second matrix, we get

$$\begin{bmatrix}
2(1) + 1(0) + 0(3) & 2(2) + 1(-1) + 0(0) \\
-1(1) + 3(0) + 4(3) & -1(2) + 3(-1) + 4(0)
\end{bmatrix}.$$

Multiplying we obtain

$$\begin{bmatrix}
2 + 0 + 0 & 4 – 1 + 0 \\
-1 + 0 + 12 & -2 – 3 + 0
\end{bmatrix}.$$

Adding and subtracting, we arrive at a final answer of

$$\begin{bmatrix}
2 & 3 \\
11 & -5
\end{bmatrix}.$$

Matrix Transpose

The transpose of a matrix is obtained by transforming rows into columns and columns into rows.

Example 5: Evaluate:
(a) $$\begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{bmatrix}^T$$
(b) $$\begin{bmatrix}
2 & -1 & 5 \\
0 & 3 & 4
\end{bmatrix}^T$$

Solution: (a) $$\begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{bmatrix}^T$$

Transforming the rows into columns and the columns into rows, we arrive at a final answer of

$$\begin{bmatrix}
1 & 4 & 7 \\
2 & 5 & 8 \\
3 & 6 & 9
\end{bmatrix}.$$

(b) $$\begin{bmatrix}
2 & -1 & 5 \\
0 & 3 & 4
\end{bmatrix}^T$$

Transforming the rows into columns and the columns into rows, we arrive at a final answer of

$$\begin{bmatrix}
2 & 0 \\
-1 & 3 \\
5 & 4
\end{bmatrix}.$$

Trace of a Matrix

The trace of a square matrix is the sum of its main diagonal entries. The trace is similar to the determinant. To learn more about determinants, please refer to the article How to Find the Determinant of a Matrix Step by Step: A Complete Beginner’s Guide.

Example 6: Evaluate:
(a) $$tr(\begin{bmatrix}
3 & 5 \\
2 & 7
\end{bmatrix})$$
(b) $$tr(\begin{bmatrix}
1 & 4 & 2 \\
0 & 5 & 3 \\
7 & 1 & 6
\end{bmatrix})$$

Solution: (a) $$tr(\begin{bmatrix}
3 & 5 \\
2 & 7
\end{bmatrix})$$

Summing the diagonal entries gives

$$3 + 7.$$

Adding we arrive at a final answer of

$$10.$$

(b) $$tr(\begin{bmatrix}
1 & 4 & 2 \\
0 & 5 & 3 \\
7 & 1 & 6
\end{bmatrix})$$

Summing the diagonal entries gives

$$1 + 5 + 6.$$

Adding we arrive at a final answer of

$$12.$$

Conclusion

In this step-by-step guide to basic matrix operations, we explored the operations of matrix addition, matrix subtraction, scalar multiplication, matrix multiplication, transpose, and trace. These operations will allow you to learn more advanced topics such as eigenvalues, eigenvectors, and linear transformations.

Further Reading

How to Solve a System of Equations Using Gaussian Elimination: A Step-by-Step Guide – Now that you are familiar with matrices, you are ready to use them to solve systems of equations.

Frequently Asked Questions

Matrix operations have many applications, including solving systems of equations, performing coordinate transformations, analyzing neural networks, and machine learning.