Tutorials › Linear Algebra › Adding Matrices Of The Same Size

Matrix Operations and Algebra · Tutorial 57 of 1000

Adding Matrices Of The Same Size

Learn to compute matrix sums and differences entry by entry, determine when these operations are defined, and verify the results.

Beginner 8 min read

What You'll Learn

  • State when two matrices can be added or subtracted.
  • Compute sums by adding entries in matching positions.
  • Compute differences by subtracting entries in matching positions.
  • Track the dimensions of a sum or difference.
  • Check matrix arithmetic against its entrywise definition.
  • Identify and correct common dimension and sign errors.

Adding Matrices Entry by Entry

Matrix addition uses a direct rule: match entries that occupy the same row and column, then add those entries. This makes the sizes of the matrices essential. A first-row, second-column entry can be paired with another first-row, second-column entry, but not with an entry in a different position. Throughout, matrices have real entries.

Let \(\mathbf{A}=[a_{ij}]\) and \(\mathbf{B}=[b_{ij}]\) be \(m\times n\) matrices. The indices \(i\) and \(j\) specify the row and column, respectively, so \(a_{ij}\) and \(b_{ij}\) occupy corresponding positions. The matrices must have the same number of rows and the same number of columns. Having the same number of entries in total is not sufficient: the arrangement into rows and columns must match.

Definition: If \(\mathbf{A}=[a_{ij}]\) and \(\mathbf{B}=[b_{ij}]\) are both \(m\times n\), their sum is the \(m\times n\) matrix \(\mathbf{A}+\mathbf{B}\) whose entry in row \(i\), column \(j\) is \(a_{ij}+b_{ij}\). Thus \((\mathbf{A}+\mathbf{B})_{ij}=a_{ij}+b_{ij}\) for every \(1\le i\le m\) and \(1\le j\le n\). If their dimensions do not match, \(\mathbf{A}+\mathbf{B}\) is not defined.

The resulting matrix has the same dimensions as each input: the rule makes one entry for every position in an \(m\times n\) matrix. Addition does not combine entries across rows or columns; each output entry is computed from exactly two entries in the same position.

Worked Example: Adding Two 2 × 2 Matrices

Find the sum of \(\mathbf{A}=\begin{bmatrix}2&-1\\4&3\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}5&6\\-2&1\end{bmatrix}\).

Both matrices are \(2\times2\), so their entries can be matched position by position. Compute each entry of the sum:

$$ \mathbf{A}+\mathbf{B} = \begin{bmatrix} 2+5&-1+6\\ 4+(-2)&3+1 \end{bmatrix} = \begin{bmatrix} 7&5\\ 2&4 \end{bmatrix}. $$

Check: The \((1,1)\) entry is \(7=2+5\), the \((1,2)\) entry is \(5=-1+6\), the \((2,1)\) entry is \(2=4+(-2)\), and the \((2,2)\) entry is \(4=3+1\). Each entry agrees with the definition, and the result is \(2\times2\).

Rectangular Matrices and Position Matching

Square matrices are not required. An \(m\times n\) matrix may be added to any other \(m\times n\) matrix, including when \(m\ne n\). The same position rule applies: row \(i\), column \(j\) is added to row \(i\), column \(j\). Writing out the entry calculations is especially helpful with rectangular matrices, because it makes the matching positions visible.

Worked Example: Adding Rectangular Matrices

Compute \(\mathbf{C}+\mathbf{D}\), where

$$ \mathbf{C}= \begin{bmatrix} 1&0&-3\\ 2&5&4 \end{bmatrix}, \qquad \mathbf{D}= \begin{bmatrix} -2&7&1\\ 6&-1&0 \end{bmatrix}. $$

Both matrices have two rows and three columns. Add corresponding entries, keeping the first row paired with the first row and the second row paired with the second row:

$$ \mathbf{C}+\mathbf{D} = \begin{bmatrix} 1+(-2)&0+7&-3+1\\ 2+6&5+(-1)&4+0 \end{bmatrix} = \begin{bmatrix} -1&7&-2\\ 8&4&4 \end{bmatrix}. $$

Check: Reading the result position by position gives \(-1=1+(-2)\), \(7=0+7\), \(-2=-3+1\), \(8=2+6\), \(4=5+(-1)\), and \(4=4+0\). The answer is \(2\times3\), matching both inputs.

The rule also tells us precisely why matching dimensions are required. Every entry of one matrix has to be paired with the entry of the other matrix in the same row and column. If the row counts or column counts differ, at least one matrix has a position for which its proposed partner does not exist—or the two layouts do not describe the same set of positions. The entrywise addition rule therefore does not define a sum in that situation.

Theorem: For two real matrices, their sum is defined exactly when they have the same dimensions. When \(\mathbf{A}\) and \(\mathbf{B}\) are both \(m\times n\), there is exactly one \(m\times n\) matrix \(\mathbf{C}\) satisfying \(c_{ij}=a_{ij}+b_{ij}\) for every position \((i,j)\).

Proof. First suppose \(\mathbf{A}\) and \(\mathbf{B}\) both have dimensions \(m\times n\). For each pair of indices \(i,j\) with \(1\le i\le m\) and \(1\le j\le n\), the real numbers \(a_{ij}\) and \(b_{ij}\) have a sum \(a_{ij}+b_{ij}\). Place this sum in position \((i,j)\) of \(\mathbf{C}\). Doing so for every such pair constructs an \(m\times n\) matrix satisfying the stated entry formula, so such a matrix exists. If \(\mathbf{C}\) and \(\mathbf{D}\) both satisfy the formula, then \(c_{ij}=a_{ij}+b_{ij}=d_{ij}\) for every position. Matrices with the same dimensions and equal entries in every position are equal, so \(\mathbf{C}=\mathbf{D}\). Thus the matrix is unique. Conversely, the definition of matrix addition pairs entries at the same row and column positions and produces one entry at every position in the result. That rule applies to two matrices precisely when their row and column positions match, which requires the same number of rows and the same number of columns. \(\square\)

Subtracting Matrices Entry by Entry

Matrix subtraction follows the same position-matching requirement as addition, but subtracts the second entry from the first. The order matters: the entry from the matrix written first is the minuend, and the entry from the matrix written second is the subtrahend. In particular, \(\mathbf{A}-\mathbf{B}\) and \(\mathbf{B}-\mathbf{A}\) are computed using the same positions but with the order of the real-number subtraction reversed.

Definition: If \(\mathbf{A}=[a_{ij}]\) and \(\mathbf{B}=[b_{ij}]\) are both \(m\times n\), their difference \(\mathbf{A}-\mathbf{B}\) is the \(m\times n\) matrix whose entry in row \(i\), column \(j\) is \(a_{ij}-b_{ij}\). Thus \((\mathbf{A}-\mathbf{B})_{ij}=a_{ij}-b_{ij}\) for every \(1\le i\le m\) and \(1\le j\le n\). If the dimensions differ, the difference is not defined.

Every subtraction is ordinary real-number subtraction at one position. A negative entry in either input creates no special rule: it is still included with its sign when the corresponding entries are subtracted.

Worked Example: A Difference with Negative Entries

Find \(\mathbf{A}-\mathbf{B}\) for

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

Both matrices are \(2\times3\). Subtract the entry of \(\mathbf{B}\) from the entry of \(\mathbf{A}\) in each position:

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

Check: The entries are \(3=4-1\), \(-5=-3-2\), \(6=2-(-4)\), \(6=0-(-6)\), \(2=5-3\), and \(-3=-1-2\). This confirms the result position by position, including the two subtractions in which a negative number is subtracted.

Theorem: If \(\mathbf{A}\) and \(\mathbf{B}\) are real matrices of the same dimensions, then \(\mathbf{A}-\mathbf{B}=\mathbf{O}\) if and only if \(\mathbf{A}=\mathbf{B}\), where \(\mathbf{O}\) is the zero matrix of those dimensions.

Proof. Let the common dimensions be \(m\times n\). By the definition of difference, the entry in position \((i,j)\) of \(\mathbf{A}-\mathbf{B}\) is \(a_{ij}-b_{ij}\). If \(\mathbf{A}-\mathbf{B}=\mathbf{O}\), every entry of the difference is zero, so \(a_{ij}-b_{ij}=0\) for every \(i,j\). Hence \(a_{ij}=b_{ij}\) at every position, and the matrices are equal. For the reverse direction, suppose \(\mathbf{A}=\mathbf{B}\). Equality of matrices means \(a_{ij}=b_{ij}\) for every position. Therefore \(a_{ij}-b_{ij}=0\) for every position, so every entry of \(\mathbf{A}-\mathbf{B}\) is zero. Thus \(\mathbf{A}-\mathbf{B}=\mathbf{O}\). \(\square\)

Worked Example: Checking a Difference Against the Inputs

Let \(\mathbf{P}=\begin{bmatrix}3&1\\-2&4\end{bmatrix}\) and \(\mathbf{Q}=\begin{bmatrix}5&-3\\1&-1\end{bmatrix}\). Compute \(\mathbf{P}-\mathbf{Q}\), then check that every entry follows the subtraction rule.

Subtract corresponding entries in the order \(\mathbf{P}\) minus \(\mathbf{Q}\):

$$ \mathbf{P}-\mathbf{Q} = \begin{bmatrix} 3-5&1-(-3)\\ -2-1&4-(-1) \end{bmatrix} = \begin{bmatrix} -2&4\\ -3&5 \end{bmatrix}. $$

Check: In position \((1,1)\), \(-2=3-5\); in position \((1,2)\), \(4=1-(-3)\); in position \((2,1)\), \(-3=-2-1\); and in position \((2,2)\), \(5=4-(-1)\). Every output entry is the first input entry minus the second input entry in that position.

Common Mistakes and Reliable Checks

Adding matrices with different dimensions. A tempting but incorrect calculation is to add \(\begin{bmatrix}1&2\\3&4\end{bmatrix}\) to \(\begin{bmatrix}5&6&7\\8&9&10\end{bmatrix}\) by using only the first two columns and ignoring the third. The first matrix is \(2\times2\), while the second is \(2\times3\). Their positions do not match, so their sum is not defined; ignoring entries does not repair the mismatch. Check both row counts and column counts before adding or subtracting.

Reversing the subtraction order. For the matrices in the last example, the \((1,2)\) entry of \(\mathbf{P}-\mathbf{Q}\) is \(1-(-3)=4\). The incorrect calculation \(-3-1=-4\) uses the entry of \(\mathbf{Q}\) first, so it computes the corresponding entry in the opposite order. To correct it, follow the expression from left to right at every position: use the entry from the first matrix, then subtract the entry from the second.

A useful check is to annotate the dimensions and inspect all positions. For matrices of size \(m\times n\), there are \(mn\) entries to compute. Each output must have the same dimensions, and each of its entries must be traceable to the two input entries in that exact position. For subtraction, also check the order explicitly, especially when negative entries occur.

Check Your Understanding

For each question, state the dimensions involved and use the entrywise rule to justify your answer.

  1. Compute \(\begin{bmatrix}2&-4\\1&0\end{bmatrix}+\begin{bmatrix}3&5\\-1&7\end{bmatrix}\).
  2. Can a \(3\times2\) matrix be added to a \(2\times3\) matrix? Explain why or why not.
  3. Compute \(\begin{bmatrix}0&6&-2\end{bmatrix}-\begin{bmatrix}-3&1&4\end{bmatrix}\).
  4. For same-sized matrices \(\mathbf{A}\) and \(\mathbf{B}\), explain why \(\mathbf{A}-\mathbf{B}=\mathbf{O}\) implies \(\mathbf{A}=\mathbf{B}\).
  5. Find and correct the sign error in the claim that the \((1,2)\) entry of \(\begin{bmatrix}4&-2\end{bmatrix}-\begin{bmatrix}1&3\end{bmatrix}\) is \(3-(-2)\).

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