Mathwords logoMathwords

Compatible Matrices

Compatible Matrices

Two matrices with dimensions arranged so that they may be multiplied. The number of columns of the first matrix must equal the number of rows of the second.

 

Two examples: A (2×3) and B (3×10) are compatible for AB (inner dimensions match). B (3×10) and A (2×3) are not compatible for BA.

 

 

See also

Matrix multiplication

Key Formula

Am×nBn×p=Cm×pA_{m \times n} \cdot B_{n \times p} = C_{m \times p}
Where:
  • AA = The first matrix, with m rows and n columns
  • BB = The second matrix, with n rows and p columns
  • CC = The resulting product matrix, with m rows and p columns
  • mm = Number of rows in matrix A
  • nn = Number of columns in A, which must equal the number of rows in B
  • pp = Number of columns in matrix B

Worked Example

Problem: Determine whether matrices A and B are compatible for multiplication, and if so, find the dimensions of the product. A is a 2×3 matrix and B is a 3×4 matrix.
Step 1: Identify the dimensions of each matrix.
A is 2×3andB is 3×4A \text{ is } 2 \times 3 \quad \text{and} \quad B \text{ is } 3 \times 4
Step 2: Check the compatibility condition: the number of columns of A must equal the number of rows of B.
Columns of A=3,Rows of B=3\text{Columns of } A = 3, \quad \text{Rows of } B = 3
Step 3: Since 3 = 3, the matrices are compatible for multiplication.
3=33 = 3 \quad \checkmark
Step 4: Determine the dimensions of the product matrix. The result takes the rows of A and the columns of B.
AB=C2×4A \cdot B = C_{2 \times 4}
Answer: Matrices A and B are compatible. Their product is a 2×4 matrix.

Another Example

This example involves three matrices and tests multiple products, showing that compatibility depends on order and that both AB and BA can be defined yet yield different-sized results.

Problem: Given three matrices — A (2×3), B (3×2), and C (2×5) — determine which of the products AB, BA, and AC are defined, and give the dimensions of each valid product.
Step 1: Check AB: columns of A (3) vs. rows of B (3).
A2×3B3×2:3=3Product is 2×2A_{2 \times 3} \cdot B_{3 \times 2}: \quad 3 = 3 \quad \checkmark \quad \Rightarrow \text{Product is } 2 \times 2
Step 2: Check BA: columns of B (2) vs. rows of A (2).
B3×2A2×3:2=2Product is 3×3B_{3 \times 2} \cdot A_{2 \times 3}: \quad 2 = 2 \quad \checkmark \quad \Rightarrow \text{Product is } 3 \times 3
Step 3: Check AC: columns of A (3) vs. rows of C (2).
A2×3C2×5:32×A_{2 \times 3} \cdot C_{2 \times 5}: \quad 3 \neq 2 \quad \times
Step 4: Summarize results. Notice that AB and BA are both defined but produce matrices of different sizes. This illustrates that matrix multiplication is not commutative — even when both orders are valid, the results differ.
AB is 2×2,BA is 3×3,AC is undefinedAB \text{ is } 2 \times 2, \quad BA \text{ is } 3 \times 3, \quad AC \text{ is undefined}
Answer: AB is defined (2×2), BA is defined (3×3), and AC is not defined because the inner dimensions do not match.

Frequently Asked Questions

What makes two matrices compatible for multiplication?
Two matrices are compatible for multiplication when the number of columns in the first matrix equals the number of rows in the second. For example, a 4×3 matrix can multiply a 3×7 matrix because the inner dimensions (both 3) match. If they don't match, the multiplication is undefined.
Does the order of multiplication matter for compatible matrices?
Yes, order matters significantly. If A is 2×3 and B is 3×5, then AB is defined but BA is not (5 ≠ 2). Even when both AB and BA are defined, they generally produce different matrices with potentially different dimensions. Matrix multiplication is not commutative.
Can two square matrices always be multiplied together?
Two square matrices can be multiplied only if they are the same size. A 3×3 matrix and a 3×3 matrix are always compatible because the inner dimensions match. However, a 2×2 matrix and a 3×3 matrix are not compatible because 2 ≠ 3.

Compatible Matrices (for multiplication) vs. Compatible Matrices (for addition)

Compatible Matrices (for multiplication)Compatible Matrices (for addition)
ConditionColumns of first = Rows of second (inner dimensions match)Both matrices must have exactly the same dimensions
ExampleA (2×3) and B (3×4) → product is 2×4A (2×3) and B (2×3) → sum is 2×3
Result dimensionsRows of first × Columns of second (outer dimensions)Same dimensions as both original matrices
Order matters?Yes — AB and BA may not both be definedNo — A + B = B + A always

Why It Matters

You encounter compatible matrices whenever you solve systems of linear equations using matrix methods, apply transformations in computer graphics, or work with data in statistics. Checking compatibility is the very first step before performing any matrix multiplication — attempting to multiply incompatible matrices is undefined and a common source of errors in both hand calculations and programming. Understanding this concept also prepares you for linear algebra courses where matrix products appear constantly.

Common Mistakes

Mistake: Checking whether the rows (not columns) of the first matrix equal the columns (not rows) of the second matrix.
Correction: The rule involves the inner dimensions: columns of the first matrix must equal rows of the second. A quick way to remember: write the dimensions side by side (e.g., 2×3 and 3×4) and check that the two middle numbers match.
Mistake: Assuming that if AB is defined, then BA is also defined.
Correction: This is only guaranteed when both matrices are square and the same size. For non-square matrices, AB being defined says nothing about BA. Always check each product separately.

Related Terms