# Matrices, Part 2

In order to set up a system of equations using matrices, you need to understand how matrices multiply one another. Not all matrices can be multiplied together – they need to be compatible with one another. Not only that, unlike scalar (single number) arithmetic, multiplication does not commute, that is, the order of the multiplication will generally produce different results or one order may not even be possible. So what do I mean by compatible?

$\begin{array}{l} {\left[{\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}}\right]\times\left[{\begin{array}{cc}{5}&{6}\\{7}&{8}\end{array}}\right]\hspace{0.33em}{=}\hspace{0.33em}\left[{\begin{array}{cc}{{(}{5}\times{1}{)}{+}{(}{7}\times{2}{)}}&{{(}{6}\times{1}{)}{+}{(}{8}\times{2}{)}}\\{{(}{5}\times{3}{)}{+}{(}{7}\times{4}{)}}&{{(}{6}\times{3}{)}{+}{(}{8}\times{4}{)}}\end{array}}\right]}\\ {{=}\hspace{0.33em}\left[{\begin{array}{cc}{19}&{22}\\{43}&{50}\end{array}}\right]} \end{array}$

To multiply these two 2 × 2 matrices, you take the first column of the second matrix and lay it over the top of the first matrix:

$\begin{array}{l} {\left[{\begin{array}{cc}{5}&{7}\end{array}}\right]}\\ {\left[{\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}}\right]} \end{array}$

Starting with the top row of the first matrix, Multiply the numbers in the same position together and add the result of each: (5 × 1) + (7 × 2) = 19. This result is the first row, first column number in the new matrix. Repeat this using the second row of the first matrix: (5 × 3) + (7 × 4) = 43. This is the first element of the second row of the new matrix. Now do the same with the second column of the second matrix:

$\begin{array}{l} {\left[{\begin{array}{cc}{6}&{8}\end{array}}\right]}\\ {\left[{\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}}\right]} \end{array}$

to get the second column of the new matrix. I will leave it as an exercise for you to confirm that if I reverse the order of the matrices, you will get a different result. That is,

$\left[{\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}}\right]\times\left[{\begin{array}{cc}{5}&{6}\\{7}&{8}\end{array}}\right]\hspace{0.33em}\ne\hspace{0.33em}\left[{\begin{array}{cc}{5}&{6}\\{7}&{8}\end{array}}\right]\hspace{0.33em}\times\hspace{0.33em}\left[{\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}}\right]$

So this method works for any size matrices as long as they are compatible. From this example, you see that this works only if the second matrix has the same number of rows as the number of columns in the first matrix. This is easy to see if you put the dimensions together: (2 × 2) × (2 × 2). The inside numbers need to be the same if multiplication is possible (2 = 2). The outside numbers give the dimensions of the resulting matrix (2 × 2).

So you can multiply a 3 × 2 matrix by a 2 × 4 matrix to get a 3 × 4 matrix, but you cannot reverse the order because the inside dimensions will not be equal. It’s interesting that if you multiply a 1 × (anything) matrix by a (same anything) × 1 matrix, you will get a 1 × 1 matrix which is just a number (a scalar).

This multiplication works even if some or all of the elements of the matrices are variables. I will illustrate this in my next post.