Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I understand that when you want to multiply two matrices that the number of rows in the left matrix have to be equal to the number of columns in the right, otherwise the result of the multiplication is undefined.

So this is okay:


This is undefined:


But what exactly happens here?


The number of rows in the first matrix is equal to the number of columns in the second matrix, so by what I've been reading online this is doable. I'm just not sure how to accomplish this because all the examples I've seen only have shown the first example where there multiplication of elements is 1:1, I haven't seen any examples explaining what to do in the third case.

If I was to guess, I would say that we're supposed to multiply all the elements through but I want to know what the actual rule and process for this is before I commit something incorrect to memory by guessing.

Thanks to all in advance, I know this question is a bit simplistic.

share|cite|improve this question
It's the number of columns in the first matrix that has to be equal to the number of rows in the second matrix. – Qiaochu Yuan May 20 '14 at 17:13
up vote 0 down vote accepted

The inner dimensions need to match (# of columns in first matrix = # of rows in second matrix). If $A$ is m by n (m rows, n columns), and $B$ is n by p, then $AB$ is m by p (and is undefined otherwise). The i-j'th component (ith row, jth column) of $AB$ is the $i$-th row of $A$ dotted with the $j$-th column of $B$.

Thus, the final matrix multiplication is undefined.

share|cite|improve this answer
Okay thanks a ton. Between your answer and Qiaochu Yuan's comment it clicked in my head and I get it now. Thanks for your help! – BCqrstoO May 21 '14 at 5:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.