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 proves 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:
How to multiply matrices?
As we said, 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
A and a matrix
B, then in general, the matrix product
A * B is different from
B * A (we say that multiplying matrices is not commutative). Let's see the formula for array multiplication to see why it is so.
A has entries an,m, where
n denotes the number of the row, and
m denotes the column. This means that an entry of a2,4 would refer to the number in the second row of the fourth column. Similarly, let
B have entries bn,m. If the product
A * B is a matrix with entries cn,m, then we have
cn,m = an,1 * b1,m + an,2 * b2,m + an,3 * b3,m + ...
In other words, to obtain the entry in row
n and column
m of the matrix product, we need to take the
n-th row of the first matrix and the
m-th column of the second matrix and multiply their elements in pairs one by one, and then sum it all up. 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 .
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
Amust have as many entries as every column of array
B. 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 this criteria is met.
In general, the matrix product has a different shape than the factors. If the first matrix has
scolumns, and the second one has
srows (remember that this number must be the same as the number of columns in the first array) and
tcolumns, then the result of multiplying these matrices will have
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
A * B. On the other hand, if we want to find
B * A, then we would need to have
s = t, to begin with. Otherwise, multiplying these matrices is not even possible. Secondly, the product
B * Awould have
scolumns, so it would clearly be different from
A * B.
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 product calculator to learn more!
Working backwards: decomposing matrices
Just as we can factorize a number into its factors (like
24 = 2×12 = 4×6) 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.
Popular decomposition methods include the Cholesky decomposition, QR decomposition and LU decomposition.
Example: finding the matrix product
It's finally time to see how the matrix multiplication calculator works. Let's take
and let's try multiplying these matrices.
First of all, observe that
A has three rows and two columns, while
B has two rows and two columns. Therefore, according to the matrix multiplication rules, we can safely find
A * B, but the matrix product
B * A does not exist.
If you'd like the easy way out, feel free to use out 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
A, and the second one (the right one) will be
B. 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:
a₁ = 3,
a₂ = -1,
b₁ = 0,
b₂ = 2,
c₁ = 1,
c₂ = -1,
and for the second:
x₁ = 1,
x₂ = 0,
y₁ = -1,
y₂ = 4.
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 first column will correspond to multiplying the first column of the first row of
A by the first row of the first column of
B, multiplying the second column of the first row of
A by the second row of the first column of
B, and summing the results. This gives:
3 * 1 + (-1) * (-1) = 3 + 1 = 4.
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
|A * B||=||