# What’s the point of a matrix?

by Ebrahim Patel & Andrew Irving (on Tuesday 14th October 2014)

Suppose we take x to represent the distance I must walk from my house to work. Then 2x represents the total distance I would walk in one day’s journey to work. The distance I walk from my house to work is x

Now, what if I also walk from work to a nearby place for lunch?  Let us represent this distance by y so that 2y gives the distance form work to lunch and back.

We could describe all of my journeys in this way, e.g. walking from home to the park on a Saturday, walking from home into town to do some shopping on a Sunday.

If we list all of my possible journeys, labelling their distances as x(1), x(2), …, x(n) respectively (where n is the total number of different journeys undertaken), then these can be represented by a size n vector

x = (x(1), x(2), …, x(n)).

Suppose that I also want to record the total distance I walk on each day of the 7-day week.  Then this can be represented by a size 7 vector

d = (d(1), d(2), …, d(7))

where d(1) represents the total distance walked on Monday, d(2) for Tuesday, and so on.

These vectors, x and d, are clearly linked.  And the link between them can be described by a matrix M.

The first row of will represent Monday: the number of times I take the first journey will be entered into position M(11), the number of times I take the second journey is M(12), and so on.

So each row of M represents a day of the week (giving it 7 rows) while each column represents one of my possible journeys (giving it n columns).  M is therefore a 7 × n matrix.

When multiplied by the vector x, we get the vector d, i.e. M.x = d, or

As you may know, a vector is just a list of numbers. A matrix is then just a list of vectors!

In fact, matrix multiplication is a lot like vector multiplication, essentially using the same mechanism – the dot product (or scalar product). Here, row i of d is equal to the dot product of x and row i of M.

Now that we have the basics, let us show how all this can be so useful.  A new colleague wants to know the closest place for lunch – they’ve come to the right person!

Because, as I like to know if I do enough exercise, I wear a pedometer. This records my daily walking (i.e. my pedometer tells me all numerical values of d) whilst I record all values of M myself.

For my colleague, I need to find which one of my various lunch terms (in vector x) is the smallest – I need x.  Well, I know that M.x= d but how do I rearrange for x?

If this were a scalar equation (say, m.x = d where m, x, and d are all scalars), then we would simply divide by m on both sides to give x = d/m.  Put another way, we would multiply each side by the inverse of m.

And indeed that is the approach we take with our matrix-vector equation.  Thus, we find x by multiplying both sides of M.x= by the inverse of M (denoted inv(M)) to give,

x = inv(M).d

noting that the right hand side gives a vector of known numerical values, as required.*  A complicated problem is thereby reduced to a simple one using matrices.

So, matrices are an extension to scalar arithmetic – they allow us to multiply, add, and solve equations for many different scenarios in one fell swoop – a short-cut for large scale arithmetic.

——————————————————————————–

Enjoy this blog?  Why not click “Like”!

* Although some matrices do not, the matrix M is assumed to have an inverse here.

## 2 thoughts on “What’s the point of a matrix?”

1. Gilbert says:

You post very interesting posts here. Your website
deserves much bigger audience. It can go viral if you give it initial