Rectangular Matrix Multiplication
Multiply non-square matrices step by step · 직사각 행렬 곱셈
1. What Is Rectangular Matrix Multiplication?
Rectangular matrix multiplication is ordinary matrix multiplication applied to non-square matrices — ones where the number of rows differs from the number of columns. The same row-by-column dot-product rule applies, but the shapes need extra care: you can only multiply two matrices when the inner dimensions match.
This is the general case. Square multiplication is just the special case where both matrices happen to be n×n. Rectangular products show up constantly — a data matrix times a weight vector, an image filter, or a change of coordinates between spaces of different dimension.
직사각 행렬 곱셈은 행과 열 수가 다른 비정사각 행렬에 대한 일반적인 행렬 곱셈입니다. 동일한 "행 × 열" 규칙을 쓰되, 두 행렬의 안쪽 차원이 일치할 때만 곱할 수 있습니다. 정사각 곱셈은 n×n인 특수한 경우일 뿐입니다.
2. The Dimension Rule
To multiply A (size m×n) by B (size p×q), the inner dimensions must be equal: n = p. The product then has the outer dimensions:
(m × n) · (n × q) = (m × q)
If the inner dimensions disagree, the product is simply undefined.
A(m×n)와 B(p×q)를 곱하려면 안쪽 차원이 같아야 합니다(n = p). 그러면 곱은 바깥 차원 (m×q)가 됩니다. 안쪽 차원이 다르면 곱은 정의되지 않습니다.
3. Worked Example: 2×3 times 3×2
Let A = [[1, 2, 3], [4, 5, 6]] (2×3) and B = [[7, 8], [9, 10], [11, 12]] (3×2). The inner dimensions are both 3, so the product is 2×2. Each entry is a row of A dotted with a column of B:
- c₁₁ = 1·7 + 2·9 + 3·11 = 7 + 18 + 33 = 58
- c₁₂ = 1·8 + 2·10 + 3·12 = 8 + 20 + 36 = 64
- c₂₁ = 4·7 + 5·9 + 6·11 = 28 + 45 + 66 = 139
- c₂₂ = 4·8 + 5·10 + 6·12 = 32 + 50 + 72 = 154
AB = [[58, 64], [139, 154]]
A = [[1, 2, 3], [4, 5, 6]] (2×3), B = [[7, 8], [9, 10], [11, 12]] (3×2)이면 안쪽 차원이 3으로 같아 곱은 2×2가 됩니다. 결과는 AB = [[58, 64], [139, 154]] 입니다.
4. Order Matters Even More
With rectangular matrices, order is not just about getting a different answer — reversing it can make the product impossible. In the example above, AB is defined and 2×2. The reverse, BA, multiplies a 3×2 by a 2×3: the inner dimensions (2 and 2) match, so BA is defined, but it comes out 3×3 — a completely different shape from AB.
Often only one order is even valid. Always check inner dimensions before computing, and remember the result takes the outer dimensions.
직사각 행렬에서는 순서를 바꾸면 답이 달라질 뿐 아니라 곱 자체가 불가능해질 수 있습니다. 위 예에서 AB는 2×2지만, BA는 3×2 × 2×3이라 3×3로 크기가 전혀 다릅니다. 한쪽 순서만 유효한 경우도 많으니, 계산 전 안쪽 차원을 반드시 확인하세요.
5. Frequently Asked Questions
When can you multiply two rectangular matrices? When the number of columns of the first equals the number of rows of the second — the inner dimensions must match.
What size is the result? The outer dimensions: an (m×n)(n×q) product is m×q.
Does order matter for rectangular matrices? Yes — even more than for square ones. Swapping the order can change the result’s shape or make the product undefined entirely.
첫 행렬의 열 수 = 둘째 행렬의 행 수일 때 곱할 수 있습니다. 결과 크기는 바깥 차원 (m×q)입니다. 순서를 바꾸면 크기가 달라지거나 곱이 정의되지 않을 수 있습니다.
Ready to practice? Drill rectangular products and the rest of linear algebra on C:Matrix, or review the full matrix reference and the related matrix multiplication and transpose.