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.
BA is a 2×2 matrix with (BA)2=[30117−63−87], whereas B2 is undefined because B is 2×3; so (BA)2=B2A2.
The first thing to fix is the shapes. A is 3×2 and B is 2×3. The product BA is (2×3)(3×2)=2×2 — square, so it can be squared. But B2=B⋅B would be (2×3)(2×3), and the inner dimensions (3 and 2) don't match, so B2does not exist. That single observation already tells us the two sides cannot be equal, but let us compute (BA)2 so the left side is explicit.
Mistake 1: Assuming B2 exists for a rectangular B.
Why it's wrong: B is 2×3, so B⋅B needs 3=2 and is undefined; hence B2A2 does not exist. Correct approach: test conformability of every power before computing.
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.