A Reliable Order for Mixed Matrix Expressions
A matrix expression can involve several familiar operations at once: addition, scalar multiplication, multiplication, transposition, and powers. The main challenge is often not a difficult computation but keeping track of which operations are defined and which rearrangements are valid. Matrices are not numbers: in general, \(\mathbf{A}\mathbf{B}\ne\mathbf{B}\mathbf{A}\), and changing the order of factors can change the answer.
For a matrix in \(\mathbb{R}^{m\times n}\), its dimensions are \(m\times n\). Addition requires matrices of the same dimensions. The product of an \(m\times n\) matrix and a \(p\times q\) matrix is defined only when \(n=p\), and then has dimensions \(m\times q\). A transpose exchanges rows and columns, so an \(m\times n\) matrix has an \(n\times m\) transpose. A power \(\mathbf{A}^k\) is defined when \(\mathbf{A}\) is square and \(k\) is a nonnegative integer; for \(k\geq1\), it means \(k\) copies of \(\mathbf{A}\) multiplied together, while \(\mathbf{A}^0=\mathbf{I}\) of the same size.
For instance, if \(\mathbf{A}\) is \(2\times3\) and \(\mathbf{B}\) is \(3\times4\), then \(\mathbf{A}\mathbf{B}\) is defined and is \(2\times4\). But \(\mathbf{B}\mathbf{A}\) is not defined, because the inner dimensions would be \(4\) and \(2\). Even for square matrices, where both products may exist, their values need not agree. These checks should happen before any arithmetic.
Dimension Checks and Algebraic Rules
The dimension rules explain why some expressions are meaningful and others are not. They also help catch an error before it spreads through a longer calculation.
Proof. The entry in position \((i,j)\) of a sum is \(a_{ij}+b_{ij}\), so both matrices must have an entry at every same position. This requires equal numbers of rows and equal numbers of columns. For a product, its \((i,j)\) entry is \(\sum_{k=1}^{n}a_{ik}b_{kj}\). Each term requires a column index \(k\) in \(\mathbf{A}\) to match a row index \(k\) in \(\mathbf{B}\); this is possible exactly when the number of columns of \(\mathbf{A}\) equals the number of rows of \(\mathbf{B}\). The resulting entry is indexed by a row \(i\) of \(\mathbf{A}\) and a column \(j\) of \(\mathbf{B}\), giving \(m\) rows and \(q\) columns. Transposition interchanges the row and column indices, so the dimensions become \(n\times m\). \(\square\)
Several identities are especially useful in mixed expressions. Each identity below is understood only when all displayed operations are defined. Multiplication is associative, so parentheses in a product may be regrouped without changing factor order; this does not permit swapping the factors.
- \((\mathbf{A}+\mathbf{B})\mathbf{C}=\mathbf{A}\mathbf{C}+\mathbf{B}\mathbf{C}\) and \(\mathbf{A}(\mathbf{B}+\mathbf{C})=\mathbf{A}\mathbf{B}+\mathbf{A}\mathbf{C}\).
- \((\mathbf{A}\mathbf{B})\mathbf{C}=\mathbf{A}(\mathbf{B}\mathbf{C})\).
- \((\mathbf{A}\mathbf{B})^{\top}=\mathbf{B}^{\top}\mathbf{A}^{\top}\).
Proof. Write the entries of the matrices as \(a_{ij},b_{ij},c_{ij}\). For left distributivity, the \((i,j)\) entry of \((\mathbf{A}+\mathbf{B})\mathbf{C}\) is \(\sum_k(a_{ik}+b_{ik})c_{kj}\), which equals \(\sum_k a_{ik}c_{kj}+\sum_k b_{ik}c_{kj}\) by distributivity of real numbers. This is the \((i,j)\) entry of \(\mathbf{A}\mathbf{C}+\mathbf{B}\mathbf{C}\). The right-distributive identity follows because the \((i,j)\) entry of \(\mathbf{A}(\mathbf{B}+\mathbf{C})\) is \(\sum_k a_{ik}(b_{kj}+c_{kj})=\sum_k a_{ik}b_{kj}+\sum_k a_{ik}c_{kj}\). For associativity, the \((i,j)\) entry of either grouping is \(\sum_k\sum_{\ell}a_{i\ell}b_{\ell k}c_{kj}\); changing the order of these finite sums gives the same value. For the transpose identity, the \((i,j)\) entry of \((\mathbf{A}\mathbf{B})^{\top}\) is \((\mathbf{A}\mathbf{B})_{ji}=\sum_k a_{jk}b_{ki}\), which is exactly the \((i,j)\) entry of \(\mathbf{B}^{\top}\mathbf{A}^{\top}\). Finally, the power identity holds for \(k=0\) because \(\mathbf{I}^{\top}=\mathbf{I}\). For \(k\geq1\), applying the transpose-of-a-product identity repeatedly reverses the order of \(k\) identical factors, leaving \(k\) factors \(\mathbf{A}^{\top}\). \(\square\)
Worked Calculations with Dimensions Shown
Worked Example: A Transpose, Product, Scalar Multiple, and Sum
Let \(\mathbf{A}=\begin{bmatrix}1&0&2\\-1&1&1\end{bmatrix}\), \(\mathbf{B}=\begin{bmatrix}2&1\\0&3\end{bmatrix}\), and \(\mathbf{C}=\begin{bmatrix}1&0\\0&-1\\2&1\end{bmatrix}\). Evaluate \(\mathbf{A}^{\top}\mathbf{B}+2\mathbf{C}\).
The dimensions are \(2\times3\), \(2\times2\), and \(3\times2\), respectively. Thus \(\mathbf{A}^{\top}\) is \(3\times2\), so \(\mathbf{A}^{\top}\mathbf{B}\) is \(3\times2\). The sum with \(2\mathbf{C}\) is defined because \(\mathbf{C}\) is also \(3\times2\).
Now multiply each entry of \(\mathbf{C}\) by \(2\), then add corresponding entries:
Check: The product entries are \(2,-2,0,3,4,5\), obtained from the indicated row-by-column products; the scalar multiple contributes \(2,0,0,-2,4,2\). Adding these entry by entry gives \(4,-2,0,1,8,7\), as in the result. The final matrix is \(3\times2\), which agrees with the dimensions of both terms being added.
Worked Example: Transposing a Product Reverses Its Order
Using \(\mathbf{A}=\begin{bmatrix}1&2\\-1&3\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}2&0\\1&1\end{bmatrix}\), calculate \((\mathbf{A}\mathbf{B})^{\top}\) and compare it with \(\mathbf{B}^{\top}\mathbf{A}^{\top}\). Both matrices are \(2\times2\), so all products shown are defined.
First multiply in the given order:
Now transpose each factor and multiply in reversed order:
The two calculations agree, as the transpose-of-a-product rule predicts. For comparison, multiplying in the unreversed order gives \(\mathbf{A}^{\top}\mathbf{B}^{\top}=\begin{bmatrix}2&0\\4&5\end{bmatrix}\), which is not the transpose of \(\mathbf{A}\mathbf{B}\). The order reversal is essential.
Check: Transposing the computed product \(\begin{bmatrix}4&2\\1&3\end{bmatrix}\) exchanges its off-diagonal entries, yielding \(\begin{bmatrix}4&1\\2&3\end{bmatrix}\). This is exactly the product \(\mathbf{B}^{\top}\mathbf{A}^{\top}\).
Worked Example: Expanding a Square of a Matrix Sum
For the same square matrices \(\mathbf{A}\) and \(\mathbf{B}\), evaluate \((\mathbf{A}+\mathbf{B})^2-\mathbf{A}^2-\mathbf{B}^2\). A square is a product of a matrix with itself, so the expression is defined.
First add the matrices and square the result:
Compute the two other powers separately:
Therefore, first add the powers and then subtract entry by entry:
Check: Direct multiplication gives \(\mathbf{A}\mathbf{B}=\begin{bmatrix}4&2\\1&3\end{bmatrix}\) and \(\mathbf{B}\mathbf{A}=\begin{bmatrix}2&4\\0&5\end{bmatrix}\). Their sum is \(\begin{bmatrix}6&6\\1&8\end{bmatrix}\), matching the evaluated expression. This is consistent with the distributive expansion \((\mathbf{A}+\mathbf{B})^2=\mathbf{A}^2+\mathbf{A}\mathbf{B}+\mathbf{B}\mathbf{A}+\mathbf{B}^2\).
Why Matrix Order Cannot Be Ignored
For real numbers, \((a+b)^2=a^2+2ab+b^2\), because \(ab=ba\). For matrices, distributivity instead gives \((\mathbf{A}+\mathbf{B})^2=\mathbf{A}^2+\mathbf{A}\mathbf{B}+\mathbf{B}\mathbf{A}+\mathbf{B}^2\). The middle terms may be combined as \(2\mathbf{A}\mathbf{B}\) only if \(\mathbf{A}\mathbf{B}=\mathbf{B}\mathbf{A}\). That condition must be checked; it cannot be presumed.
Common mistake. A tempting but incorrect calculation for the matrices above is to replace \((\mathbf{A}+\mathbf{B})^2\) by \(\mathbf{A}^2+2\mathbf{A}\mathbf{B}+\mathbf{B}^2\). In this case, that proposed result is
But the direct calculation gave \((\mathbf{A}+\mathbf{B})^2=\begin{bmatrix}9&14\\0&16\end{bmatrix}\), so the proposed expansion is wrong. The correction is to retain both cross-products: \(\mathbf{A}\mathbf{B}+\mathbf{B}\mathbf{A}=\begin{bmatrix}6&6\\1&8\end{bmatrix}\). Adding this to \(\mathbf{A}^2+\mathbf{B}^2=\begin{bmatrix}3&8\\-1&8\end{bmatrix}\) gives \(\begin{bmatrix}9&14\\0&16\end{bmatrix}\).
A useful working sequence for a longer expression is:
Record the size of each matrix, and check every sum and product before calculating.
Evaluate the indicated parentheses and powers. Regroup a product only by associativity; do not interchange factors.
Use transpose, distributive, and power rules only in forms that preserve dimensions and factor order.
Verify key products entry by entry and confirm that the final dimensions match the original expression.
These habits matter because a valid calculation is a chain of defined operations, not merely a sequence of plausible-looking symbols. Dimension checks detect undefined expressions; order checks detect false rearrangements; and a direct multiplication check helps identify arithmetic slips. With those safeguards, a complicated expression can be reduced to manageable sums and products without relying on numerical shortcuts that do not hold for matrices.
Check Your Understanding
For each question, check dimensions before carrying out any arithmetic.
- If \(\mathbf{P}\) is \(3\times2\) and \(\mathbf{Q}\) is \(2\times4\), what are the dimensions of \(\mathbf{P}\mathbf{Q}\)? Is \(\mathbf{Q}\mathbf{P}\) defined?
- For compatible matrices, write the correct product in terms of transposes that equals \((\mathbf{A}\mathbf{B})^{\top}\).
- Expand \((\mathbf{A}+\mathbf{B})^2\) without assuming that \(\mathbf{A}\mathbf{B}=\mathbf{B}\mathbf{A}\).
- What dimensions must \(\mathbf{A}\) have for \(\mathbf{A}^3\) to be defined?
- Explain why \(\mathbf{A}^{\top}\mathbf{B}^{\top}\) is not generally equal to \((\mathbf{A}\mathbf{B})^{\top}\).