For two matrices to be multiplied, the length of the rows of the first matrix must match the length of the columns of the second (in other words, the number of columns in the first matrix must match the number of rows in the second).

The resulting matrix formed will have the same number of rows as the first matrix and the same number of columns as the second. That is, the product of a matrix #A_(lm)# with #l# rows and #m# columns and a matrix #B_(mn)# with #m# rows and #n# columns will be a matrix #C_(ln)# with #l# rows and #n# columns.

#A_(color(blue)(l) color(red)(m))*B_(color(red)(m)color(green)(n)) = C_(color(blue)(l)color(green)(n))#

To perform the actual multiplication, the entry in the #i^(th)# row and #j^(th)# column of #C# is the sum of the products of the #i^(th)# row of #A# and the #j^(th)# column of #B#.

#c_(ij) = sum_(k=1)^ma_(ik)b_(kj)#

Let's look at an example. We will multiply the following matrices:

#A = ((2,1,4),(3,-2,5))# and #B = ((3,2,4,1),(2,2,6,3),(-8,0,2,-1))#

Note that #A# is #2# by #3# and #B# is #3# by #4#. Thus the resulting matrix #C# will be #2# by #4#.

#((2,1,4),(3,-2,5))((3,2,4,1),(2,2,6,3),(-8,0,2,-1))=((c_11,c_12,c_13,c_14),(c_21,c_22,c_23,c_24))#

Again, to find #c_(ij)# we multiply the #i^(th)# row of #A# by the #j^(th)# row of #B#. So, to find #c_11#, for example,

#((color(red)(2),color(red)(1),color(red)(4)),(3,-2,5))((color(red)(3),2,4,1),(color(red)(2),2,6,3),(color(red)(-8),0,2,-1))=((color(red)(c_11),c_12,c_13,c_14),(c_21,c_22,c_23,c_24))#

#c_11 = 2*3 + 1*2 + 4*(-8) = -24#

Similarly, for #c_23# we have

#((2,1,4),(color(red)(3),color(red)(-2),color(red)(5)))((3,2,color(red)(4),1),(2,2,color(red)(6),3),(-8,0,color(red)(2),-1))=((c_11,c_12,c_13,c_14),(c_21,c_22,color(red)(c_23),c_24))#

#c_23 = 3*4+(-2)*6+5*2 = 10#

After performing all of the operations, the result becomes

#((2,1,4),(3,-2,5))((3,2,4,1),(2,2,6,3),(-8,0,2,-1))=((-24,6,22,1),(-35,2,10,-8))#

(For practice, try seeing if you get the same result)