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.
Concept: Matrix Multiplication Compatibility — the product is defined only when the inner dimensions match, and here we multiply a 1×3 row, a 3×3 matrix, and a 3×1 column to get a 1×1 scalar (zero).
Step 1: Multiply the row vector by the matrix first:
The key idea is that the product of a row vector, a 3×3 matrix, and a column vector yields a single number (a scalar). Setting that scalar to zero gives a quadratic in x, which solves to x=−2 or x=−14.
We start with the expression
[1x1]121535321212x=O,
where O here means the zero scalar (the number 0). The product is a 1×1 matrix, i.e., a number.
Why multiply in this order?
Matrix multiplication is associative, so we can either multiply the row vector with the matrix first, or the matrix with the column vector first. Both give the same final scalar. We'll do the first multiplication: row vector times matrix, which yields another row vector. Then multiply that row vector by the column vector to get the scalar.
Multiply the row vector by the matrix
Let
r=[1x1],M=1215353212.
The product rM is a 1×3 row vector. Each entry is the dot product of r with the corresponding column of M.
First column: 1⋅1+x⋅2+1⋅15=1+2x+15=2x+16.
Second column: 1⋅3+x⋅5+1⋅3=3+5x+3=5x+6.
Third column: 1⋅2+x⋅1+1⋅2=2+x+2=x+4.
So
rM=[2x+165x+6x+4].
Multiply this row vector by the column vector
The column vector is
Mistake 1: Treating the row-times-matrix result as a scalar.
Why it's wrong: [1x1] times the 3×3 matrix is still a 1×3 row; only after multiplying by the 3×1 column do you get a number. Correct approach: carry the intermediate row, then contract with the column.
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.