Fibonacci 1.5 – Matrices

If you know about matrices, you can probably skip this. If you aren’t sure, or you think it’s that one Keanu movie, read on!

A matrix is, at heart, a way of structuring information. In our case, it’s for arranging numbers. A matrix looks like this:

All diagrams drawn with Latex

This is a 4×4 matrix – it’s 4 entries wide, and 4 entries long. Matrices can be any (whole) number wide, and any number long, to store whatever information is needed (for example, 1×3, 2×7, 7×4, 5×5). The entries can be anything, although for our purposes they’ll be numbers.

It also helps here to define a few special matrices – A square matrix has the same number of rows and columns. All of the matrix stuff we’ll be looking at uses square matrices. A square matrix with only 1’s along the main diagonal is called an “identity” matrix, and it’s essentially the matrix equivalent of the number 1, because if you multiply another matrix by the identity, it gets back the original matrix.

Identity matrix.PNG
The 3×3 identity

Matrices can also be combined, a bit like numbers. You can add matrices – to add them, they must be the same dimensions, e.g. both are 5×4. Note that 5×4 and 4×5 can’t be added, as the dimensions are the wrong way around. To add two matrices, you simply take each term, and add it to the term in the same position in the other matrix. For example:


This is merely a single position being added, to represent how it works – all of these numbers are in row 1, and column 2. In general, addition of matrices looks like this:

Addition of Matrices.PNG

You can also subtract matrices in the same fashion.

Multiplying by a scalar
Multiplying a matrix by a simple number is easy – you just have to multiply every term in the matrix by the number. You can also divide by a number, just by dividing each term by that number.

Multiplying two matrices
Next is multiplication of two matrices – it’s a little more complicated. Say you want to multiply AxB, where A and B are two matrices. Firstly, you need the number of columns of your first matrix, A, to be equal to the number of rows of your second matrix, B. For example, A can be 3×4, and B can be 4×5. (The reason why will become clear after explaining the process). For example, these two can be multiplied:


Now, the actual process is a little confusing. Essentially, to find the top left hand term of the answer matrix, you multiply the first entry in the first row of A by the first entry in the first column of B, and then multiply the second entry in the first row of A by the second entry in the first column of B, and so on – this is why the number of rows of A and columns of B must be equal. Next, you take all these terms and add them together, and this is your first entry into the answer. Here is a visual explanation:


To get the second entry in the first row of the answer, you multiply the first row of A by the second column of B, and so on. When you want to get to the second and third and so on rows of an answer, you just shift from the first row of A to the second row, and then the third, and so on.

In general, if you consider the process described in the image above to be multiplying one row by one column, to find the entry (i,j) in the answer (where “i” is the row, and “j” is the column), you multiply the “i”th row of A by the “j”th column of B.

“Dividing” matrices by other matrices
Now, onto division, and here we hit a snag – you can’t divide matrices. You can, however, multiply by an inverse. The inverse of a matrix is another matrix, and if you multiply some matrix by its inverse, you get back the identity. This is essentially the matrix equivalent of dividing a number by itself to get one. This means that, instead of dividing by a matrix A, you multiply by the inverse of A. Note that not all matrices have inverses.

In general, it doesn’t matter a huge amount if you don’t understand precisely how these operations are carried out – it just helps to know they can be done.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

Up ↑

%d bloggers like this: