The product C of two matrices A and B is defined as

 c_(ik)=a_(ij)b_(jk),
(1)

where j is summed over for all possible values of i and k and the notation above uses the Einstein summation convention. The implied summation over repeated indices without the presence of an explicit sum sign is called Einstein summation, and is commonly used in both matrix and tensor analysis. Therefore, in order for matrix multiplication to be defined, the dimensions of the matrices must satisfy

 (n×m)(m×p)=(n×p),
(2)

where (a×b) denotes a matrix with a rows and b columns. Writing out the product explicitly,

 [c_(11) c_(12) ... c_(1p); c_(21) c_(22) ... c_(2p); | | ... |; c_(n1) c_(n2) ... c_(np)]=[a_(11) a_(12) ... a_(1m); a_(21) a_(22) ... a_(2m); | | ... |; a_(n1) a_(n2) ... a_(nm)][b_(11) b_(12) ... b_(1p); b_(21) b_(22) ... b_(2p); | | ... |; b_(m1) b_(m2) ... b_(mp)],
(3)

where

c_(11)=a_(11)b_(11)+a_(12)b_(21)+...+a_(1m)b_(m1)
(4)
c_(12)=a_(11)b_(12)+a_(12)b_(22)+...+a_(1m)b_(m2)
(5)
c_(1p)=a_(11)b_(1p)+a_(12)b_(2p)+...+a_(1m)b_(mp)
(6)
c_(21)=a_(21)b_(11)+a_(22)b_(21)+...+a_(2m)b_(m1)
(7)
c_(22)=a_(21)b_(12)+a_(22)b_(22)+...+a_(2m)b_(m2)
(8)
c_(2p)=a_(21)b_(1p)+a_(22)b_(2p)+...+a_(2m)b_(mp)
(9)
c_(n1)=a_(n1)b_(11)+a_(n2)b_(21)+...+a_(nm)b_(m1)
(10)
c_(n2)=a_(n1)b_(12)+a_(n2)b_(22)+...+a_(nm)b_(m2)
(11)
c_(np)=a_(n1)b_(1p)+a_(n2)b_(2p)+...+a_(nm)b_(mp).
(12)

Matrix multiplication is associative, as can be seen by taking

 [(ab)c]_(ij)=(ab)_(ik)c_(kj)=(a_(il)b_(lk))c_(kj),
(13)

where Einstein summation is again used. Now, since a_(il), b_(lk), and c_(kj) are scalars, use the associativity of scalar multiplication to write

 (a_(il)b_(lk))c_(kj)=a_(il)(b_(lk)c_(kj))=a_(il)(bc)_(lj)=[a(bc)]_(ij).
(14)

Since this is true for all i and j, it must be true that

 (ab)c=a(bc).
(15)

That is, matrix multiplication is associative. Equation (13) can therefore be written

 [abc]_(ij)=a_(il)b_(lk)c_(kj),
(16)

without ambiguity. Due to associativity, matrices form a semigroup under multiplication.

Matrix multiplication is also distributive. If A and B are m×n matrices and C and D are n×p matrices, then

A(C+D)=AC+AD
(17)
(A+B)C=AC+BC.
(18)

Since n×n matrices form an Abelian group under addition, n×n matrices form a ring.

However, matrix multiplication is not, in general, commutative (although it is commutative if A and B are diagonal and of the same dimension).

The product of two block matrices is given by multiplying each block

 [o o    ; o o    ;   o   ;    o o o;    o o o;    o o o][x x    ; x x    ;   x   ;    x x x;    x x x;    x x x] 
 =[[o o; o o][x x; x x]  ;  [o][x] ;   [o o o; o o o; o o o][x x x; x x x; x x x]].
(19)