Matrix Multiplication Calculator
Welcome to the matrix multiplication calculator, where we'll go through the subject of multiplying matrices together, and see what it is good for. Unfortunately, a matrix product is something slightly more complicated than a regular multiplication. But don't worry, it's not rocket science, and learning how to multiply matrices does prove useful in fields such as algebra, analysis, and, believe it or not, real life.
No time to waste; let's learn how to multiply matrices!
What is a matrix, and what is it good for?
The answer to the above question is not, unfortunately, absolutely nothing. Before we start with the matrix multiplication calculator, let's think of a number. Don't worry; this is not the beginning of a magic trick. We leave those for when we want to impress our date. Anyway, the number that popped into your head can mean anything, from the number of books you've read in the past few months to the number of calories you're going to burn by reading this text. Infinitely many possibilities, right?
A matrix is a generalization of that. It is an array of elements (usually numbers) with a set number of rows and columns. In particular, a matrix with one row and one column contains only one element, so we can think of such an array as a single number. In general, however, it can store more information than a single value since... well, you can have as many rows and columns as you like. The numbers they contain could be your working hours and your wage or the finish time of the first three marathon runners in each of the last ten Olympic Games.
And if you'd like an example of what mathematicians use matrices for, then let us give you a taste by saying that every linear transformation, i.e., translation or rotation of an element can be described by a matrix. In other words, every summer that you've gone on a road trip and every Saturday morning that you've mixed ingredients for pancakes, you have, in fact, used matrices. Or, to be precise, the motion could be translated into a matrix. Now that sounds like something you can tell at a party after a beer or two. We're sure your friends will be sufficiently impressed.
Other scientific areas that rely heavily on matrices include:
- Systems of equations;
- Vectors and vector spaces;
- 3-dimensional geometry (e.g., the dot product and the cross product);
- Eigenvalues and eigenvectors; and
- graph theory and discrete mathematics.
How to multiply matrices?
As we said in the section above, matrices are generalizations of simple numbers, so it makes sense to multiply them. There are, however, a few matrix multiplication rules that we must follow, and, unfortunately, matrix product may not be as intuitive as regular number product.
First of all, we can't multiply any pair of matrices. Even worse, if we have a matrix and a matrix , then in general, the matrix product is different from (we say that multiplying matrices is not commutative). Let's see the formula for array multiplication to see why it is so.
Say that has entries , where denotes the number of the row, and denotes the column. This means that an entry of would refer to the number in the second row of the fourth column. Similarly, let have entries . If the product is a matrix with entries , then we have:
In other words, to obtain the entry in row and column of the matrix product, we need to take the row of the first matrix and the column of the second matrix and multiply their elements in pairs one by one, and then sum it all up, as we did in our dot product calculator, between vectors. Well, we did warn you that array multiplication is not as intuitive as the regular one. But don't you worry, we'll see a nice example of how to multiply matrices in the next section.
However, before we try multiplying matrices, let's take note of the few matrix multiplication rules that we've mentioned.
-
We can't multiply any pair of matrices. From the formula above, we see that every entry of the matrix product is obtained by pairing a row of the first matrix with a column of the second matrix and multiplying their entries one after another. This means that every row of array must have as many entries as every column of array . This, in turn, translates to the first matrix having as many columns as the second matrix has rows. Observe that our matrix multiplication calculator won't work unless these criteria is met.
-
In general, the matrix product has a different shape than the factors. If the first matrix has rows and columns, and the second one has rows (remember that this number must be the same as the number of columns in the first array) and columns, then the result of multiplying these matrices will have rows and columns.
-
Array multiplication is not commutative. We've already mentioned this one, but now that we've learned how to multiply matrices, we see why this is the case. In the above point, we've said that a product of an -row and -column matrix with an -row and -column matrix is an -row and -column array . On the other hand, if we want to find , then we would need to have to begin with. Otherwise, multiplying these matrices is not even possible. Secondly, the product would have rows and columns, so it would clearly be different from .
-
It indeed is a generalization of regular numbers. As the last of the matrix multiplication rules, we note that it all works nice and pretty in the most basic cases - when both factors are single-entry matrices. Then, the matrix product is a single-entry matrix, which we obtain by multiplying the numbers from the two arrays. This operation is commutative and behaves just the way regular number multiplication does.
🙋 Hey, do you know that there are also other definitions of the matrix product? Check out our [Kronecker matrix tensor product calculator to learn more!
Working backwards: decomposing matrices
Just as we can factorize a number into its factors (like ) we can factorize a matrix into matrices that will result in our original matrix when multiplied together as we've discussed above.
As matrices are a bit more complicated than singular numbers, these methods of factorization are trickier.
We described some popular decomposition methods in a very specific set of tools:
Example: finding the matrix product
It's finally time to see how the matrix multiplication calculator works. Let's take
And:
And let's try multiplying these matrices.
First of all, observe that has three rows and two columns, while has two rows and two columns. Therefore, according to the matrix multiplication rules, we can safely find , but the matrix product does not exist.
If you'd like the easy way out, feel free to use our matrix multiplication calculator to find the answer. To do this, we begin by inputting the number of rows and columns for both of the matrices. This will show us a symbolic picture above the calculator, complete with the notation we use. The first one (the one to the left) will be our , and the second one (the right one) will be . Compare the picture with the arrays we have and type the numbers into the matrix multiplication calculator under the correct labels. For the first matrix, we have:
Then:
And finally:
And for the second:
And:
Nevertheless, let's also see how the matrix multiplication calculator finds the answer. We start by introducing a useful trick that will help us with the array multiplication. We write the two matrices in a particular way, separating them by a pair of dotted perpendicular lines:
The product of the two matrices must have three rows and two columns, so we will write it in the bottom right corner of the table above. Observe that the entry in the first row and the first column will correspond to multiplying the first column of the first row of by the first row of the first column of , multiplying the second column of the first row of by the second row of the first column of , and summing the results. This gives:
Therefore, if we write it in the correct cell of our table like this
We put this new number where the column and row we used to calculate it intersect, so we know what we used to find it. If we continue this procedure, we get:
All in all, the result of our array multiplication is:
⌈ | ⌉ | × | ⌈ | ⌉ | = | ⌈ | ⌉ | ||||||
⌊ | ⌋ | ⌊ | ⌋ | ⌊ | ⌋ |