# How do you multiply matrices?

### 1 Answer | Add Yours

There are several ways to multiply two matrices and there are many matrix multiplication algorithms. But the most common (and usually the easiest way for humans) is so called row times column.

Let `A=[(a_(11),a_(12),ldots,a_(1n)),(a_(21),a_(22),ldots,a_(2n)),(vdots,vdots,ddots,vdots),(a_(m1),a_(m2),ldots,a_(mn))]` , `B=[(b_(11),b_(12),ldots,b_(1m)),(b_(21),b_(22),ldots,b_(2m)),(vdots,vdots,ddots,vdots),(b_(n1),b_(n2),ldots,b_(nm))]` and`C=A*B` then

`[c_(ij)]=a_(i1)b_(1j)+a_(i2)b_(2j)+cdots+a_(in)b_(nj)=sum_(k=1)^n a_(ik)b_(kj)`

Here `c_(ij)` represents element of matrix `C` (that is product of A and B) at i-th row and j-th column.

This formula may seam complicated but once you get used to it, it's really simple. Here is one example

`A=[(1,2,3),(3,2,1)],` `B=[(2,5),(3,4),(1,0)]`

`A*B=[(1*2+2*3+3*1,1*5+2*4+3*0),(3*2+2*3+1*1,3*5+2*4+1*0)]`

`A*B=[(11,13),(13,23)]`

You can make product of two matrices only if the number of columns of the first is equal to number of rows of the second matrix.

Also matrix multiplication is not commutative i.e. `ABneBA`