Matrix Multiplication Compatibility: The Inner-Dimensions Rule
You cannot multiply just any two matrices. Multiplication is defined only when their sizes line up in a specific way, and this compatibility check is always the very first step of any product.
The Idea: A Row Meets a Column
When you multiply A by B, you take each row of A and pair it against each column of B, multiply corresponding entries, and add. For that pairing to work, a row of A must have exactly as many entries as a column of B.
Note
Think of a handshake: each finger of one hand must meet a finger of the other. If one hand has 4 fingers and the other has 3, the handshake fails.
The Precise Statement
Let A be m×n and B be p×q.
A×B is defined if and only if n=p — the number of columns of A equals the number of rows of B. The product C=AB then has order m×q.
Writing the sizes side by side, (m×n)(p×q), the inner numbers (n,p) must match; the outer numbers (m,q) give the result's shape.
Why the Rule Exists
Each entry of the product is
cij=∑k=1naikbkj.
Here k runs over the columns of A (up to n) and the rows of B (up to p). If n=p, the sum runs out of matching terms and is meaningless — that is exactly why compatibility demands n=p.
Watch out
Even when both AB and BA are defined, they usually differ. For A of order 2×3 and B of order 3×2, AB is 2×2 but BA is 3×3 — different sizes entirely. Matrix multiplication is not commutative.
No. Since (AB)2=ABAB but A2B2=AABB, the two are equal only when BA=AB, and matrix multiplication is not commutative in general. A 3×3 counterexample: with
No. In general (AB)2=A2B2, because matrix multiplication is not commutative; a 3×3 counterexample confirms it.
The reasoning
By definition, (AB)2=(AB)(AB)=ABAB, while A2B2=(AA)(BB)=AABB. These two agree only if the middle factors can be swapped, i.e. only if BA=AB. Since matrix multiplication is generally not commutative, the equality fails in general.
Method: Testing whether a matrix "identity" is true — expand, then check commutativity
Many questions ask whether a familiar scalar identity (here (AB)2=A2B2) carries over to matrices. The reliable method is to expand both sides by the definition of a power and see whether the orderings can only match if the matrices commute — then confirm with a counterexample.
Steps
Step 1: Expand each power as repeated multiplication, keeping the order.
(AB)2=(AB)(AB)=ABAB,A2B2=AABB.
Matrix multiplication is associative, so brackets can be dropped, but the left-to-right order must be preserved.
Step 2: Compare the two strings of factors.
ABAB versus AABB differ only in the middle: they are equal for all A,B only if BA=AB, i.e. only if A and B commute. …
Mistake 1: Treating matrices like numbers and writing (AB)2=A2B2 as automatically true.
Why it's wrong: the scalar rule relies on ab=ba; matrices generally satisfy AB=BA, so ABAB cannot be rearranged into AABB. Correct approach: expand keeping order and note the identity needs commutativity.
Mistake 2: Picking a counterexample that accidentally gives equality and stopping there. …
The expression A2+B(A+B) simplifies to (A+B)2−AB by using the distributive property of matrix multiplication. We calculate (A+B)2 and then subtract AB to find the result 431646623.
The core idea here is to simplify the given expression A2+B(A+B) using the properties of matrix algebra, specifically the distributive property of matrix multiplication over addition. We are given A+B and AB, so we should try to express the target expression in terms of these known quantities.
First, let's expand B(A+B):
B(A+B)=BA+B2
So, the expression we need to evaluate becomes:
A2+B(A+B)=A2+BA+B2
Now, let's recall the expansion of (A+B)2 for matrices:
For matrices A and B, (A+B)2=(A+B)(A+B)=A(A+B)+B(A+B)=A2+AB+BA+B2.
Watch out
It is crucial to remember that matrix multiplication is generally not commutative, meaning AB=BA. Therefore, (A+B)2 is not equal to A2+2AB+B2 unless AB=BA.
Comparing the expression we need, A2+BA+B2, with the expansion of (A+B)2, which is A2+AB+BA+B2, we can see a direct relationship.
If we subtract AB from (A+B)2, we get:
(A+B)2−AB=(A2+AB+BA+B2)−AB
=A2+(AB−AB)+BA+B2
=A2+0+BA+B2
=A2+BA+B2
This shows that A2+B(A+B)=(A+B)2−AB. This simplification is key because we are given A+B and AB directly.