Tutorials › Linear Algebra › Mixed Matrix Algebra Calculation Workshop

Matrix Operations and Algebra · Tutorial 85 of 1000

Mixed Matrix Algebra Calculation Workshop

Learn a reliable order for evaluating expressions that combine matrix sums, scalar multiples, products, transposes, and powers.

Beginner 9 min read

What You'll Learn

  • Check dimensions before adding matrices or multiplying them.
  • Evaluate grouped expressions without changing the order of matrix factors.
  • Apply transpose and distributive laws with their correct conditions.
  • Expand squares of matrix sums without assuming matrix multiplication commutes.
  • Verify a mixed-expression calculation by direct multiplication and addition.

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.

Calculation rule: Before evaluating an expression, record the dimensions of every matrix and check each operation. Follow the parentheses, keep the factors in their given order, and use a matrix identity only when its dimensions and hypotheses allow it. Addition and scalar multiplication act entry by entry; matrix multiplication does not generally commute.

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.

Proposition: Suppose \(\mathbf{A}\in\mathbb{R}^{m\times n}\) and \(\mathbf{B}\in\mathbb{R}^{p\times q}\). The sum \(\mathbf{A}+\mathbf{B}\) is defined exactly when \(m=p\) and \(n=q\). The product \(\mathbf{A}\mathbf{B}\) is defined exactly when \(n=p\), and then belongs to \(\mathbb{R}^{m\times q}\). If \(\mathbf{A}\) is \(m\times n\), then \(\mathbf{A}^{\top}\) is \(n\times m\).

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.

Proposition (Rules for mixed calculations): For compatible matrices \(\mathbf{A},\mathbf{B},\mathbf{C}\), and a scalar \(c\in\mathbb{R}\), the following hold:
  • \((\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}\).
Consequently, for a square matrix \(\mathbf{A}\) and integer \(k\geq0\), \((\mathbf{A}^k)^{\top}=(\mathbf{A}^{\top})^k\).

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\).

$$ \mathbf{A}^{\top} =\begin{bmatrix}1&-1\\0&1\\2&1\end{bmatrix}, \qquad \mathbf{A}^{\top}\mathbf{B} =\begin{bmatrix} 1(2)+(-1)0&1(1)+(-1)3\\ 0(2)+1(0)&0(1)+1(3)\\ 2(2)+1(0)&2(1)+1(3) \end{bmatrix} =\begin{bmatrix}2&-2\\0&3\\4&5\end{bmatrix}. $$

Now multiply each entry of \(\mathbf{C}\) by \(2\), then add corresponding entries:

$$ 2\mathbf{C} =\begin{bmatrix}2&0\\0&-2\\4&2\end{bmatrix}, \qquad \mathbf{A}^{\top}\mathbf{B}+2\mathbf{C} =\begin{bmatrix}2+2&-2+0\\0+0&3+(-2)\\4+4&5+2\end{bmatrix} =\begin{bmatrix}4&-2\\0&1\\8&7\end{bmatrix}. $$

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:

$$ \mathbf{A}\mathbf{B} =\begin{bmatrix} 1(2)+2(1)&1(0)+2(1)\\ (-1)2+3(1)&(-1)0+3(1) \end{bmatrix} =\begin{bmatrix}4&2\\1&3\end{bmatrix}, \qquad (\mathbf{A}\mathbf{B})^{\top} =\begin{bmatrix}4&1\\2&3\end{bmatrix}. $$

Now transpose each factor and multiply in reversed order:

$$ \mathbf{B}^{\top}\mathbf{A}^{\top} =\begin{bmatrix}2&1\\0&1\end{bmatrix} \begin{bmatrix}1&-1\\2&3\end{bmatrix} =\begin{bmatrix} 2(1)+1(2)&2(-1)+1(3)\\ 0(1)+1(2)&0(-1)+1(3) \end{bmatrix} =\begin{bmatrix}4&1\\2&3\end{bmatrix}. $$

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:

$$ \mathbf{A}+\mathbf{B} =\begin{bmatrix}3&2\\0&4\end{bmatrix}, \qquad (\mathbf{A}+\mathbf{B})^2 =\begin{bmatrix}3&2\\0&4\end{bmatrix} \begin{bmatrix}3&2\\0&4\end{bmatrix} =\begin{bmatrix}9&14\\0&16\end{bmatrix}. $$

Compute the two other powers separately:

$$ \mathbf{A}^2 =\begin{bmatrix}1&2\\-1&3\end{bmatrix} \begin{bmatrix}1&2\\-1&3\end{bmatrix} =\begin{bmatrix}-1&8\\-4&7\end{bmatrix}, \qquad \mathbf{B}^2 =\begin{bmatrix}2&0\\1&1\end{bmatrix} \begin{bmatrix}2&0\\1&1\end{bmatrix} =\begin{bmatrix}4&0\\3&1\end{bmatrix}. $$

Therefore, first add the powers and then subtract entry by entry:

$$ \mathbf{A}^2+\mathbf{B}^2 =\begin{bmatrix}3&8\\-1&8\end{bmatrix}, \qquad (\mathbf{A}+\mathbf{B})^2-\mathbf{A}^2-\mathbf{B}^2 =\begin{bmatrix}9-3&14-8\\0-(-1)&16-8\end{bmatrix} =\begin{bmatrix}6&6\\1&8\end{bmatrix}. $$

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

$$ \mathbf{A}^2+2\mathbf{A}\mathbf{B}+\mathbf{B}^2 =\begin{bmatrix}-1&8\\-4&7\end{bmatrix} +\begin{bmatrix}8&4\\2&6\end{bmatrix} +\begin{bmatrix}4&0\\3&1\end{bmatrix} =\begin{bmatrix}11&12\\1&14\end{bmatrix}. $$

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:

1
Annotate dimensions.
Record the size of each matrix, and check every sum and product before calculating.
2
Respect grouping and order.
Evaluate the indicated parentheses and powers. Regroup a product only by associativity; do not interchange factors.
3
Apply identities carefully.
Use transpose, distributive, and power rules only in forms that preserve dimensions and factor order.
4
Check the result.
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.

  1. 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?
  2. For compatible matrices, write the correct product in terms of transposes that equals \((\mathbf{A}\mathbf{B})^{\top}\).
  3. Expand \((\mathbf{A}+\mathbf{B})^2\) without assuming that \(\mathbf{A}\mathbf{B}=\mathbf{B}\mathbf{A}\).
  4. What dimensions must \(\mathbf{A}\) have for \(\mathbf{A}^3\) to be defined?
  5. Explain why \(\mathbf{A}^{\top}\mathbf{B}^{\top}\) is not generally equal to \((\mathbf{A}\mathbf{B})^{\top}\).

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon