In general, if A is an matrix (meaning it has m rows and n columns), the matrix product AB will exist if and only if the matrix B has n rows. If B is an matrix, AB will be an matrix. In general, if A is an matrix (meaning it has m rows and n columns), the matrix product AB will exist if and only if the matrix B has n rows. If B is an matrix, AB will be an matrix.

When multiplying one matrix by another, the number of columns of the matrix on the left must be equal to the number of rows of the matrix on the right. The number of rows of the resulting matrix will be equal to the number of rows of the matrix on the left, and the number of columns will be equal to the number of columns of the matrix on the right.

For (AB)C to exist, C must have p rows (the same number of rows as columns of AB). If C is a matrix, (AB)C will be an matrix.

If (AB)C exists, A(BC) will also exist and have the same shape as (AB)C. For these matrices to exist, A must have the same number of columns as B has rows, and C must have the same number of rows as B has columns. If B is an matrix, for BC to exist, C must have p rows. If C is a matrix, BC will be an matrix. If (AB)C exists, that means that AB exists. If BC is an matrix, then A must have n columns. If A is an matrix, A(BC) will be an matrix. So if A is an matrix, B is an matrix, and C is a matrix, it follows that (AB)C and A(BC) both exist and are matrices.

When (AB)C and A(BC) both exist, . To prove this, all we must do is prove that an arbitrary column of AB(C) will be equal to the same arbitrary column in A(BC).

If represents the i-th column of any matrix K, matrix B can be represented as

is the i-th column of B, and is a vector with n rows. The i-th column of AB is equal to A times the i-th column of B.

The j-th column of the matrix C can be represented as

is the value in row i, column j of C.

Column j of (AB)C is equal to AB times column j of C. This is equal to the linear combination of the i-th columns of (AB) with the i-th values in .

The j-th column of BC is equal to , which is equal to the linear combination of the i-th columns of B with the i-th values in :

The j-th column of A(BC) is equal to the jth column of BC, times A.

Since the j-th column of (AB)C is equal to the j-th column of A(BC), it follows that .