# Is the matrix dot product of a $3\times 2$ Matrix with a $2\times 3$ Matrix the same as doing the $2\times 3$ Matrix by the $3\times 2$ Matrix?

I'm a little bit confused with matrix dot products.

I'm aware that for a matrix dot product to be defined we require that the number of columns of the first matrix is equal to the number of rows of the second matrix.

Visually it looks like the first matrix is horizontal while the second matrix is vertical.

Consider a matrix $$A$$ which is $$3 \times 2$$ and matrix $$B$$ which is $$2 \times 3$$.

The confusion occurs when I try to think of a matrix $$A$$ which is $$2 \times 3$$ that we multiply to a matrix $$B$$ that is $$3 \times 2$$. It doesn't seem to be against the rules of the matrix dot product however visually the first matrix looks vertical while the second looks horizontal.

My question is: Is this valid? If yes are they both equivalent?

• If $A$ is $3\times2$ and $B$ is $2\times3$ then both $AB$ and $BA$ are defined, but they're definitely not equal. One is $3\times3$ and the other $2\times2$ Sep 3 '20 at 22:01

It is unclear what you mean by "equivalent" here. We can multiply matrices whenever the number of column of the first one is equal to the number of the rows of second, i.e. generically we can multiply a $$m \times k$$ matrix by a $$k \times n$$ matrix, the resulting matrix is $$m \times n$$.

It doesn't matter which matrix "looks horizontal" and which "looks vertical". For example, we can multiply a $$1 \times 10$$ matrix times a $$10 \times 2$$ matrix and alternatively, we can multiply a $$10 \times 1$$ by a $$1 \times 11$$ matrix. Though these look like very different situations, they are both well-defined mathematical operations.

Given two matrices $$A \in \mathbb{R}^{m\times n}, X\in \mathbb{R}^{n\times p}$$

The dot product of $$A$$ and $$B$$ is Not commutative:

$$AB \neq BA$$

We have

$$AB \in \mathbb{R}^{m\times p}$$

but the product $$BA$$ can't be possible because $$p \neq m$$