MathAlgebraLinear algebraMatrices

Operations with matrices

3 minutes read

We often need to work with matrices. For example, you take a look at the monthly sales table and decide to find out how many items were sold during the last five years. Here's another example: you multiply the table with the number of office supplies by the number of offices to find out how much stuff you have to buy for the whole company. For all these tasks, we need to be able to perform different operations on matrices.

Today we will learn how to multiply a matrix by a scalar, add and subtract matrices, and finally, what a transposed matrix is.

Scalar multiplication

We can multiply a matrix by any number. Because this number scales the matrix, we call it a scalar, so officially it's called "scalar multiplication". To multiply a matrix by a scalar, you need to multiply each element of the matrix by that scalar.

2(203110)=(222023212120)=(406220){\color{red}-2} \cdot \begin{pmatrix} -2 & 0 & -3 \\ 1 & -1 & 0 \end{pmatrix} = \begin{pmatrix} {\color{red}-2} \cdot -2 & {\color{red}-2} \cdot 0 & {\color{red}-2} \cdot -3 \\ {\color{red}-2} \cdot 1 & {\color{red}-2} \cdot -1 & {\color{red}-2} \cdot 0 \end{pmatrix} = \begin{pmatrix} 4 & 0 & 6 \\ -2 & 2 & 0 \end{pmatrix}

We use scalar multiplication to simplify the matrix for solving a system of equations.

Matrix sum

If you need to add two matrices, they must be of the same dimension (or size). That means that they must have an equal number of rows, and also an equal number of columns.

For example, each of these matrices has two rows and three columns, so we can add them. To add two matrices, simply add the numbers in the matching positions:

(303218)+(123317)=(3+10+23+32+31+187)=(420501)\begin{pmatrix} {\color{red}3} & {\color{red}0} & {\color{red}-3} \\ {\color{red}2} & {\color{red}-1} & {\color{red}8} \end{pmatrix}+\begin{pmatrix} {\color{blue}1} & {\color{blue}2} & {\color{blue}3} \\ {\color{blue}3} & {\color{blue}1} & {\color{blue}-7} \end{pmatrix}=\begin{pmatrix} {\color{red}3}+{\color{blue}1} & {\color{red}0}+{\color{blue}2} & {\color{red}-3}+{\color{blue}3} \\ {\color{red}2}+{\color{blue}3} & {\color{red}-1}+{\color{blue}1} & {\color{red}8}{\color{blue}-7}\end{pmatrix}=\begin{pmatrix} 4 & 2 & 0 \\ 5 & 0 & 1 \end{pmatrix}

Matrix difference

In order to subtract two matrices, make sure they are the same dimension, just like in case of an addition.

To subtract two matrices, simply subtract the numbers in matching positions:

(1223)(2025)=(1(2)202235)=(3202)\begin{pmatrix} 1 & 2 \\ 2 & 3 \end{pmatrix}-\begin{pmatrix} -2 & 0 \\ 2 & 5 \end{pmatrix}=\begin{pmatrix} 1-(-2) & 2-0 \\ 2-2 & 3-5 \end{pmatrix}=\begin{pmatrix} 3 & 2 \\ 0 & -2 \end{pmatrix}

As you probably noticed, the operations of addition and subtraction are very similar. Remember that subtracting one positive number from another is the same as adding a negative number. If we calculate A=(1)A-A = (-1)\cdot A, this rule also applies to matrices, where:AB=A+(B)A - B = A + (-B)

Transposed matrix

Starting with a matrix AA, you can get a new matrix ATA^T by reflecting the elements of AA about its main diagonal so that rows become columns, and columns become rows. The superscript TT stands here for transpose. The relation between the elements of AA and the elements of ATA^T is given by ai,j=aj,iTa_{i,j} = a_{j,i}^T

For example, let's transpose this matrix:

F=(121212)F = \begin{pmatrix} 1 & 2 \\ 1 & 2 \\ 1 & 2 \end{pmatrix}

When you transpose it, you should reflect its element about its main diagonal. So, at first, you have to understand what the main diagonal of FF is. The main diagonal starts in the top-left corner and ends at the element a22a_{22} as shown by the blue color:

(121212)\begin{pmatrix} \color{blue}1 & 2 \\ 1 & \color{blue}2 \\ 1 & 2 \end{pmatrix}

Elements on the main diagonal won't change, so you should work with all other elements. a1,2=2a_{1,2}=2 and it becomes a2,1a_{2,1} after transposition. a2,1=1a_{2,1}=1 in the original matrix, and it becomes a1,2a_{1,2} after transposition. So, you already know 44 elements of the FTF^{T}. Let's write them down! Here, blue elements are the elements on the main diagonal:

(1122)\begin{pmatrix} \color{blue}1 & 1 \\ 2 & \color{blue}2 \end{pmatrix}

Let's move on to the a3,1=1a_{3,1} = 1. After transposition, it becomes a1,3a_{1,3}, so in order to write in the FTF^{T} you have to add a new column to the matrix, which you've obtained before:

(11122)\begin{pmatrix} \color{blue}1 & 1 & 1 \\ 2 & \color{blue}2 \end{pmatrix}

What about the empty space in this matrix? a3,2=2a_{3,2}=2 and it becomes a2,3a_{2,3} after transposition. You'll have 22 instead of the empty space in the FTF^{T}.

So, the result is

FT=(121212)T=(111222)F^T = \begin{pmatrix} 1 & 2 \\ 1 & 2 \\ 1 & 2 \end{pmatrix}^T=\begin{pmatrix} 1 & 1 & 1 \\ 2 & 2 &2 \end{pmatrix}

Repeating the process on the transposed matrix returns the elements to their original positions.

Matrix transposition

Conclusion

In this topic we've learned the main operations with matrices: how to add and subtract them or multiply by a scalar, and what the transpose of a matrix is. We will later need all this knowledge for our further studies, and, believe me, there will be a lot of interesting stuff!

551 learners liked this piece of theory. 8 didn't like it. What about you?
Report a typo