Matrices

Adding and Subtracting Matrices

To add matrices, add the entries that sit in the same position: (A+B)ij=aij+bij(A+B)_{ij}=a_{ij}+b_{ij}. Subtraction works the same way, (A−B)ij=aij−bij(A-B)_{ij}=a_{ij}-b_{ij}, and both operations need two matrices of identical size.

(A+B)ij=aij+bij(A+B)_{ij} = a_{ij} + b_{ij}

That is the whole mechanical rule, and it takes a minute to learn. The parts worth real attention are why the size condition exists, where signs go wrong in subtraction, how to solve equations with an unknown matrix, and quick ways to catch a mistake. Matrix multiplication is a completely different operation, and mixing the two up is the most common slip in this topic.

How do you add matrices?

Every entry in a matrix has an address: row ii, column jj. The entry at address (i,j)(i,j) in the sum is the sum of the two entries at that address.

[abcd]+[efgh]=[a+eb+fc+gd+h]\begin{bmatrix}a&b\\c&d\end{bmatrix}+\begin{bmatrix}e&f\\g&h\end{bmatrix}=\begin{bmatrix}a+e&b+f\\c+g&d+h\end{bmatrix}

There is a clean reason this is the rule and not just a convention. A matrix acts on vectors, so adding two matrices should mean adding what they do: (A+B)v=Av+Bv(A+B)\mathbf{v}=A\mathbf{v}+B\mathbf{v}. Feed in v=[10]\mathbf{v}=\begin{bmatrix}1\\0\end{bmatrix}, which picks out the first column, and the first column of A+BA+B must be the first column of AA plus the first column of BB. Feeding in [01]\begin{bmatrix}0\\1\end{bmatrix} does the same for the second column. Entry-by-entry addition is the only definition that makes this work.

Address, not appearance

The entry in row 2, column 1 only ever meets the entry in row 2, column 1 of the other matrix. Where a number appears in the grid decides its partner.

The routine is short:

  1. Compare sizes, rows by columns, and stop if they differ.
  2. Add address by address, left to right across each row.
  3. Write each result straight into an answer grid of the same size.

Why can only matrices of the same size be added?

A 2×3 grid and a 3×2 grid with unmatched entries marked, so their sum is undefined
A 2×3 and a 3×2 matrix both hold six entries, but two entries in each have no partner, so the sum is undefined.

If one matrix has an entry at row 3, column 2 and the other has no such address, that entry has nothing to be added to. The sum is not zero, it is undefined. The same logic means the answer always has the size of the inputs: two 2×32\times 3 matrices give a 2×32\times 3 matrix.

The trap is counting entries instead of checking shape. A 2×32\times 3 and a 3×23\times 2 matrix both hold six numbers, yet they cannot be added, because rows and columns must match separately. The same goes for a row vector [123]\begin{bmatrix}1&2&3\end{bmatrix} and a column vector with the same three numbers.

One exception is worth knowing so it does not confuse you later. Software such as NumPy sometimes “broadcasts” mismatched shapes and returns a result anyway. That is a programming convenience, not matrix addition as defined in algebra, and a textbook or exam will mark such a sum as undefined. If shapes are off by a transpose, check whether the problem really meant A+BTA+B^{T}, where flipping rows and columns makes the sizes agree.

Quick check

Can [123]\begin{bmatrix}1&2&3\end{bmatrix} be added to [123]\begin{bmatrix}1\\2\\3\end{bmatrix}?

Adding matrices with negatives and fractions

Treat the matrix as a set of independent small additions. Nothing carries between entries, so a negative in one slot never affects another, and a common denominator is found per entry, not for the whole matrix.

Example 1. Add the matrices.

[−4237−2]+[914−7−6]\begin{bmatrix}-4&\frac23\\7&-2\end{bmatrix}+\begin{bmatrix}9&\frac14\\-7&-6\end{bmatrix}

Top left: −4+9=5-4+9=5. Top right: 23+14=812+312=1112\frac23+\frac14=\frac{8}{12}+\frac{3}{12}=\frac{11}{12}. Bottom left: 7+(−7)=07+(-7)=0. Bottom right: −2+(−6)=−8-2+(-6)=-8.

[511120−8]\begin{bmatrix}5&\frac{11}{12}\\0&-8\end{bmatrix}

Notice that the bottom left is 00 and stays as a written 00, not a blank. A zero entry is a real entry. Decimals work the same way: line up the place values within each entry and ignore the rest of the grid.

How to subtract matrices without sign errors

Subtraction is addition of the opposite: A−B=A+(−B)A-B=A+(-B), where −B-B is BB with every entry’s sign flipped. The costly mistake is flipping the sign of only the first entry, or forgetting that subtracting a negative adds. When an expression has several matrices and parentheses, handle it as with numbers: brackets first, then left to right, the same habits drilled in order of operations practice problems.

Example 2. Compute A−BA-B for A=[5−304]A=\begin{bmatrix}5&-3\\0&4\end{bmatrix} and B=[−261−4]B=\begin{bmatrix}-2&6\\1&-4\end{bmatrix}.

Flip the signs of BB to get −B=[2−6−14]-B=\begin{bmatrix}2&-6\\-1&4\end{bmatrix}, then add:

[5−304]+[2−6−14]=[7−9−18]\begin{bmatrix}5&-3\\0&4\end{bmatrix}+\begin{bmatrix}2&-6\\-1&4\end{bmatrix}=\begin{bmatrix}7&-9\\-1&8\end{bmatrix}

Direct subtraction agrees: 5−(−2)=75-(-2)=7, −3−6=−9-3-6=-9, 0−1=−10-1=-1, 4−(−4)=84-(-4)=8. Unlike addition, order matters here. B−AB-A is the negative of A−BA-B, entry for entry.

Try this: Compute [3−215]−[−146−3]\begin{bmatrix}3&-2\\1&5\end{bmatrix}-\begin{bmatrix}-1&4\\6&-3\end{bmatrix}, then reverse the order and subtract again. Every entry of the second answer should be the opposite of the first.

Adding matrices vs. multiplying matrices

Students often try to multiply matrices the way they add them, entry with entry. That produces a real operation (the Hadamard product), but it is not what “matrix multiplication” means in a course. True multiplication combines a whole row with a whole column, so its size rules and its results are different.

Addition Multiplication
Size requirement Identical sizes Columns of first = rows of second
Size of result Same as inputs Rows of first by columns of second
Does order matter? No Yes
Entry rule Same address Row times column

Each operation also has its own neutral element. Multiplication has the identity matrix, with ones on the diagonal. Addition has the zero matrix, covered below. Keep the two apart and a lot of confusion disappears.

The one place where multiplication does behave entry by entry is multiplying by a single number: kAkA multiplies every entry by kk. That scalar operation combines freely with addition, which is what makes the next section work.

How to solve a matrix equation like A + X = B

Solving for an unknown matrix uses the same idea as solving a+x=ba+x=b: do the same thing to both sides. Subtract AA from both sides to get X=B−AX=B-A. If XX is scaled, undo the addition first and divide by the scalar last.

Example 3. Solve 3X+[4−210]=[17−59]3X+\begin{bmatrix}4&-2\\1&0\end{bmatrix}=\begin{bmatrix}1&7\\-5&9\end{bmatrix}.

Subtract the known matrix from both sides:

3X=[1−47−(−2)−5−19−0]=[−39−69]3X=\begin{bmatrix}1-4&7-(-2)\\-5-1&9-0\end{bmatrix}=\begin{bmatrix}-3&9\\-6&9\end{bmatrix}

Divide every entry by 33:

X=[−13−23]X=\begin{bmatrix}-1&3\\-2&3\end{bmatrix}

Check by substituting back: 3X=[−39−69]3X=\begin{bmatrix}-3&9\\-6&9\end{bmatrix}, and adding [4−210]\begin{bmatrix}4&-2\\1&0\end{bmatrix} gives [17−59]\begin{bmatrix}1&7\\-5&9\end{bmatrix}. This method only handles addition and scalars. If XX is multiplied by a matrix, as in AX=BAX=B, subtracting will not help, and you need the inverse of a 2×2 matrix instead.

Quick check

Solve X+[2−105]=[63−45]X+\begin{bmatrix}2&-1\\0&5\end{bmatrix}=\begin{bmatrix}6&3\\-4&5\end{bmatrix}.

Properties of matrix addition and the zero matrix

Matrix addition inherits every friendly property of ordinary addition, because each entry is just a sum of two real numbers. So A+B=B+AA+B=B+A (commutative), (A+B)+C=A+(B+C)(A+B)+C=A+(B+C) (associative), and k(A+B)=kA+kBk(A+B)=kA+kB (distributive over a scalar). None of these needs a separate proof: check one address and the rest follow.

The zero matrix

The zero matrix OO has 00 in every position, so A+O=AA+O=A for any AA of matching size. Its opposite partner is −A-A, which gives A+(−A)=OA+(-A)=O.

Because only addition and scalars are involved, a list of matrices with a constant difference behaves like a number sequence. If Ak=A+(k−1)DA_k=A+(k-1)D, then the sum of the first nn terms is n2(A1+An)\frac{n}{2}(A_1+A_n), exactly the arithmetic series formula applied to every entry at once. For instance, with A1=[1025]A_1=\begin{bmatrix}1&0\\2&5\end{bmatrix} and D=[120−1]D=\begin{bmatrix}1&2\\0&-1\end{bmatrix}, the first three terms add to 3A1+3D=[66612]3A_1+3D=\begin{bmatrix}6&6\\6&12\end{bmatrix}.

How to check a matrix sum quickly

Matrices A, B and A minus B with entry totals 6, 1 and 5 matching
The entries of A total 6, those of B total 1, and A − B correctly totals 6 − 1 = 5.

Several totals must add the way the matrices do, and they take seconds to test.

  • Size check: the answer must have the same rows and columns as the inputs.
  • Total check: the sum of all entries of A+BA+B equals the sum of all entries of AA plus the sum of all entries of BB.
  • Diagonal check: for square matrices, the diagonal total (the trace) also adds.

Apply the total check to Example 2. The entries of AA total 5−3+0+4=65-3+0+4=6, and those of BB total −2+6+1−4=1-2+6+1-4=1, so A−BA-B must total 55. The answer has 7−9−1+8=57-9-1+8=5, which matches. A match does not prove the answer is right, since two errors can cancel, but a mismatch proves a mistake.

Do not extend this to the determinant. It does not add: det⁡(A+B)≠det⁡A+det⁡B\det(A+B)\ne\det A+\det B in general. Take A=B=[1001]A=B=\begin{bmatrix}1&0\\0&1\end{bmatrix}. Each has determinant 11, but A+B=[2002]A+B=\begin{bmatrix}2&0\\0&2\end{bmatrix} has determinant 44, not 22. The formula for the determinant of a 2×2 matrix multiplies entries, which is why sums break it. The same failure appears for the determinant of a 3×3 matrix, where the products are even longer.

Quick check

Matrix AA has entries totaling 77 and matrix BB has entries totaling 1111. A student says the entries of A+BA+B total 2020. Possible?

Where adding matrices shows up in real life

The most direct use is combining tables of data. A store keeps a matrix of stock with products as rows and sizes as columns. Adding the matrices from two warehouses gives total inventory, and subtracting a sales matrix gives what remains. Because the sizes must match, the structure of the data is checked automatically.

In digital images, a grayscale picture is a matrix of brightness values. Adding a constant matrix brightens it, and subtracting one frame from another highlights what changed between two video frames. In physics and engineering, forces and stresses described by matrices are combined by superposition, which is matrix addition.

Even basic algebra fits the pattern. Store a line y=mx+by=mx+b as the row [mb]\begin{bmatrix}m&b\end{bmatrix} from slope-intercept form, and adding two rows gives the line whose slope and intercept are the sums. Subtracting a point’s row [x1y1]\begin{bmatrix}x_1&y_1\end{bmatrix} from another’s gives the displacement between them, and the ratio of its entries is the slope formula in disguise.

Practice problems

0 of 5 solved

  1. [3−142]+[56−20]\begin{bmatrix}3&-1\\4&2\end{bmatrix}+\begin{bmatrix}5&6\\-2&0\end{bmatrix}

  2. [72−3]−[4−5−1]\begin{bmatrix}7&2&-3\end{bmatrix}-\begin{bmatrix}4&-5&-1\end{bmatrix}

  3. [1234−132]+[12−1456−12]\begin{bmatrix}\frac12&\frac34\\-\frac13&2\end{bmatrix}+\begin{bmatrix}\frac12&-\frac14\\\frac56&-\frac12\end{bmatrix}

  4. Find xx and yy: [2x31y]+[y−14x]=[7255]\begin{bmatrix}2x&3\\1&y\end{bmatrix}+\begin{bmatrix}y&-1\\4&x\end{bmatrix}=\begin{bmatrix}7&2\\5&5\end{bmatrix}

  5. Solve for XX: 2X−[13−24]=[5−108]2X-\begin{bmatrix}1&3\\-2&4\end{bmatrix}=\begin{bmatrix}5&-1\\0&8\end{bmatrix}

Common questions

Can you add matrices of different sizes?

No. Adding matrices requires the same number of rows and the same number of columns, because every entry needs a partner in the same position. If the sizes differ, the sum is undefined, not zero.

How do you subtract matrices?

Subtract corresponding entries, taking the first matrix minus the second in every position. Watch the signs: subtracting a negative entry adds its absolute value.

Is matrix addition commutative?

Yes. A+B=B+AA+B=B+A because each entry is a sum of two real numbers, and real-number addition is commutative. Subtraction is not commutative, and neither is matrix multiplication.

Can you add a single number to a matrix?

Not in standard matrix algebra. A number is a scalar, and scalars multiply matrices rather than add to them. To add 33 to every entry, add a matrix of the same size filled with threes.

How do you add three or more matrices?

Add them in any grouping, since (A+B)+C=A+(B+C)(A+B)+C=A+(B+C). In practice, add the three entries at each position in one step, as long as all matrices share the same size.

What size is the sum of two matrices?

The sum has exactly the same size as the matrices you started with. Two 2×32\times 3 matrices add to a 2×32\times 3 matrix.

Up next