Matrix Addition and Subtraction

Now that we've discussed checking for equal matrices, addition and subtraction will follow quite naturally. The preceding section said that corresponding entries are positioned in the same row and column location, and if two matrices are the same size with equal corresponding entries, they must be equal. For you to add matrices, they must also have the same dimensions. You just add corresponding entries.

Adding Matrices

For two matrices of the same size, add the corresponding entries.


Always remember that two matrices must have the same dimensions for you to add them (just like equal matrices).

Also, some math texts refer to a matrix's dimensions as its order, so don't be thrown if you see that term used. ...

Get Beginning Math and Physics for Game Programmers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.