Matrix Operations Explained: Addition, Multiplication, and Solving
Adding, subtracting, and multiplying matrices, with worked numbers and the linear systems they solve.
A matrix is a rectangular grid of numbers, and matrix operations are the arithmetic of those grids: adding them entry by entry, multiplying them row by column, and using them to solve systems of equations in one stroke. The rules are few, but two of them surprise everyone the first time: multiplication needs matching inner dimensions, and order matters. This guide works every operation by hand on the same two matrices, so each rule is a number you have already seen.
- Addition and subtraction work entry by entry and need matrices of the same size; multiplication works row by column and needs the inner dimensions to match.
- With A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]], A + B = [[6, 8], [10, 12]] and A × B = [[19, 22], [43, 50]].
- Matrix multiplication is not commutative: B × A = [[23, 34], [31, 46]], a different answer from A × B.
- A system of equations is one matrix equation, A × x = b, and solving it is a single operation once the inverse exists.
What a matrix is
A matrix is a rectangular array of numbers, arranged in rows and columns, written between square brackets. A 2 × 2 matrix has 2 rows and 2 columns and 4 entries; a 3 × 2 matrix has 3 rows, 2 columns, and 6 entries. The size is always stated rows first, then columns, so a 2 × 3 matrix is not the same shape as a 3 × 2 matrix, and the two cannot be added together. Each entry is named by its position: in matrix A, the entry a₁₂ is the number in row 1, column 2.
Matrices show up wherever a table of numbers has to be manipulated as a single object. A system of equations is a matrix holding the coefficients, times a column of unknowns, equals a column of answers. A rotation in computer graphics is a matrix times a column of coordinates. A spreadsheet of sales by region and month is a matrix, and the monthly totals are a matrix times a column of ones. The operations below are the tools that make those manipulations possible, and each one has a geometric meaning as well as an arithmetic rule.
Throughout this guide, the same two matrices carry every example, so the numbers stay familiar. Let A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]]. Both are 2 × 2, both have small whole-number entries, and every operation below is worked on them in full. The calculator on this page uses these two as its defaults, so any result here can be checked by pressing a button.
Addition and subtraction: entry by entry
Adding two matrices means adding the numbers that sit in the same position. A + B is the matrix whose entry in row i, column j is aᵢⱼ + bᵢⱼ, and nothing else happens: no cross-multiplication, no carrying, no interaction between positions. With A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]], the sum is [[1 + 5, 2 + 6], [3 + 7, 4 + 8]], which is [[6, 8], [10, 12]]. Subtraction is the same with minus signs: A − B is [[1 − 5, 2 − 6], [3 − 7, 4 − 8]], which is [[−4, −4], [−4, −4]].
The one condition is size: the two matrices must have exactly the same dimensions. A 2 × 2 matrix and a 2 × 3 matrix cannot be added, because the extra column has nothing to pair with, and the operation is undefined rather than zero. This is the first of the size rules that govern matrix arithmetic, and it is the easiest to check: count the rows and the columns of both matrices, and add only when the counts agree.
Addition is commutative and associative, as ordinary addition is: A + B equals B + A, and (A + B) + C equals A + (B + C). The zero matrix, all entries zero, is the additive identity: adding it changes nothing. These properties are why addition feels familiar, and why the surprises in matrix arithmetic all live in multiplication, not here.
Scalar multiplication: one number, every entry
Multiplying a matrix by a single number, called a scalar, means multiplying every entry by that number. With A = [[1, 2], [3, 4]], twice A is 2A = [[2, 4], [6, 8]], and minus A is −A = [[−1, −2], [−3, −4]]. There is no size condition, because the scalar is not a matrix, and the operation never changes the dimensions: 2A is still 2 × 2.
Scalar multiplication is the tool for scaling and for factoring. Doubling every entry of a data matrix doubles every measurement; halving it halves them. A common factor can be pulled out of a matrix, so [[2, 4], [6, 8]] can be written as 2 × [[1, 2], [3, 4]], which is often the first step in simplifying a calculation. Scalar multiplication also combines with addition in the obvious way: 2A + 3B means double every entry of A, triple every entry of B, then add the results entry by entry.
Multiplication: rows by columns
Matrix multiplication is the operation that earns the subject its reputation, and the rule is one sentence: each entry of the product is a row of the first matrix dotted with a column of the second. To find the entry in row i, column j of A × B, take row i of A and column j of B, multiply the entries pairwise, and add. With A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]], the top-left entry is row 1 of A, [1, 2], dotted with column 1 of B, [5, 7]: 1 × 5 + 2 × 7, which is 5 + 14, which is 19. The top-right entry is [1, 2] dotted with [6, 8]: 1 × 6 + 2 × 8, which is 6 + 16, which is 22. The bottom row gives 3 × 5 + 4 × 7, which is 15 + 28, which is 43, and 3 × 6 + 4 × 8, which is 18 + 32, which is 50. The product is [[19, 22], [43, 50]].
The size rule is the inner-dimensions rule: the columns of the first matrix must equal the rows of the second. A 2 × 3 matrix can multiply a 3 × 4 matrix, giving a 2 × 4 result, but a 3 × 4 matrix cannot multiply a 2 × 3 matrix, because 4 does not equal 2, and the dot products would run out of entries. The outer dimensions survive into the answer: rows from the first matrix, columns from the second. Checking the inner numbers before starting is the habit that prevents the commonest multiplication error, which is attempting a product that does not exist.
Each entry of the product is a weighted sum, which is why matrix multiplication shows up wherever weighted sums do: a rotation matrix times a coordinate column is a weighted sum of the coordinates, and a data matrix times a weights column is a weighted sum of the data. The row-by-column rule is not an arbitrary convention; it is the arithmetic of combining rows of coefficients with columns of values.
Why order matters: AB is not BA
Matrix multiplication is not commutative: A × B is generally different from B × A, and sometimes only one of the two exists. With the same A and B, B × A is computed the same way: the top-left entry is row 1 of B, [5, 6], dotted with column 1 of A, [1, 3]: 5 × 1 + 6 × 3, which is 5 + 18, which is 23. The full product is [[23, 34], [31, 46]], where the top-right is 5 × 2 + 6 × 4, which is 10 + 24, which is 34, the bottom-left is 7 × 1 + 8 × 3, which is 7 + 24, which is 31, and the bottom-right is 7 × 2 + 8 × 4, which is 14 + 32, which is 46. Compare with A × B, [[19, 22], [43, 50]]: every entry differs. Order is part of the operation.
The reason is geometric. Each matrix is a transformation: A might rotate and B might stretch, and rotating then stretching is a different motion from stretching then rotating. The product A × B means apply B first, then A, by the usual convention for function composition, and swapping the order swaps which transformation happens first. The non-commutativity is therefore not a quirk of the arithmetic but a property of the transformations the matrices represent.
Multiplication is associative, however: (A × B) × C equals A × (B × C), so a chain of three matrices can be multiplied in either grouping with the same result, even though the order of the matrices themselves must not change. It also distributes over addition: A × (B + C) equals A × B + A × C. These two properties, with the failure of commutativity, are the complete algebra of matrix multiplication, and every manipulation in the subject follows from them.
The transpose: rows become columns
The transpose of a matrix flips it over its main diagonal: rows become columns and columns become rows. The transpose of A = [[1, 2], [3, 4]] is Aᵀ = [[1, 3], [2, 4]]: the first row, [1, 2], becomes the first column, and the second row, [3, 4], becomes the second column. The entry that was at row i, column j moves to row j, column i, and the diagonal entries, 1 and 4, stay where they are. A 2 × 3 matrix transposes into a 3 × 2 matrix, so the transpose always swaps the dimensions.
The transpose interacts neatly with the other operations. The transpose of a sum is the sum of the transposes: (A + B)ᵀ = Aᵀ + Bᵀ. The transpose of a product reverses the order: (A × B)ᵀ = Bᵀ × Aᵀ, which is the same reversal that appears in the product rule and for the same reason. Transposing twice returns the original matrix: (Aᵀ)ᵀ = A. A matrix that equals its own transpose, so aᵢⱼ = aⱼᵢ for every entry, is called symmetric, and symmetric matrices have the pleasant property that their transpose changes nothing.
Solving systems with matrices
A system of linear equations is one matrix equation. The system x + 2y = 5 and 3x + 4y = 11 has the coefficient matrix A = [[1, 2], [3, 4]], the unknown column x = [x, y], and the answer column b = [5, 11], and the whole system is A × x = b. Checking the solution x = 1, y = 2 is one multiplication: A × [1, 2] gives [1 × 1 + 2 × 2, 3 × 1 + 4 × 2], which is [5, 11], which is b, so the solution is correct.
Solving the system is the inverse operation: if A has an inverse, then x = A⁻¹ × b, a single multiplication once the inverse is known. The companion guide on finding the inverse works that step in full, with the 2 × 2 and 3 × 3 methods and the determinant test that decides whether an inverse exists at all. For the system above, the inverse of A is [[−2, 1], [1.5, −0.5]], and multiplying it by b = [5, 11] gives [−2 × 5 + 1 × 11, 1.5 × 5 + (−0.5) × 11], which is [1, 2], the solution.
This is why matrices matter beyond arithmetic: a system of ten equations in ten unknowns is the same shape, A × x = b, with a 10 × 10 coefficient matrix, and the same single operation solves it. Gaussian elimination, the method taught for solving systems by hand, is the same computation reorganised, and the determinant is the number that says in advance whether the system has exactly one solution, none, or infinitely many.
Mistakes, and a routine that always works
The commonest mistake is adding matrices of different sizes, usually by padding the smaller one with zeros without noticing. Count the rows and columns first: if they differ, the sum does not exist, and no padding fixes it without changing the problem. The second mistake is multiplying in the wrong order, or multiplying matrices whose inner dimensions do not match: check the inner numbers, the columns of the first against the rows of the second, before computing a single entry. The third mistake is assuming A × B equals B × A, which the worked example above disproves with numbers: [[19, 22], [43, 50]] against [[23, 34], [31, 46]].
The fourth mistake is a row-column slip inside a single entry: dotting a row with a row, or a column with a column, instead of a row with a column. The cure is to write the row across and the column down, and to multiply the entries that line up, first with first, second with second. The fifth mistake is dropping the sign in subtraction, especially when the second matrix has negative entries: A − B with B = [[5, 6], [7, 8]] gives [[−4, −4], [−4, −4]], and every entry is negative, which is correct, not a sign error to be fixed.
The routine that works is short. One, write down the sizes of both matrices. Two, for addition or subtraction, confirm the sizes are identical; for multiplication, confirm the inner numbers match and note the size of the answer. Three, compute one entry at a time, row by column, and write each dot product out in full before adding. Four, check the answer: for a product, verify one entry by recomputing it, and check that the result has the size predicted in step two. Five, for a system, multiply the claimed solution back through the coefficient matrix and confirm it gives the answer column.
Frequently asked questions
What is matrix multiplication?
Each entry of the product is a row of the first matrix dotted with a column of the second: multiply the entries pairwise, then add. With A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]], the top-left entry of A × B is 1 × 5 + 2 × 7 = 19, and the full product is [[19, 22], [43, 50]].
Can you add matrices of different sizes?
No. Addition and subtraction need matrices of exactly the same dimensions, because each entry pairs with the entry in the same position. A 2 × 2 matrix and a 2 × 3 matrix cannot be added, and the operation is undefined rather than zero.
Is matrix multiplication commutative?
No. A × B is generally different from B × A, and sometimes only one of the two exists. With A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]], A × B = [[19, 22], [43, 50]] while B × A = [[23, 34], [31, 46]]. Order is part of the operation.
How do you multiply a matrix by a number?
Multiply every entry by that number. Twice A = [[1, 2], [3, 4]] is [[2, 4], [6, 8]]. The size never changes, and a common factor can be pulled out: [[2, 4], [6, 8]] is 2 × [[1, 2], [3, 4]].
What is the transpose of a matrix?
The transpose flips a matrix over its main diagonal, turning rows into columns. The transpose of [[1, 2], [3, 4]] is [[1, 3], [2, 4]]. A 2 × 3 matrix transposes into a 3 × 2 matrix, and transposing twice returns the original.
When can two matrices be multiplied?
When the number of columns of the first equals the number of rows of the second. A 2 × 3 matrix times a 3 × 4 matrix works and gives a 2 × 4 matrix; a 3 × 4 matrix times a 2 × 3 matrix does not, because 4 does not equal 2.
Try it on the calculator
Check every product in this guide on the Matrix Calculator, which multiplies, adds, and inverts the same default matrices.
Open the Matrix Calculator →- 1How to Find the Inverse of a Matrix
The 2 × 2 shortcut, the 3 × 3 adjugate method, the determinant test, and how to check the answer.
- 2Algebra Calculator
Equations with steps.
- 3Graphing Calculator
Plot functions.
- 4Statistics Calculator
Mean, median, spread.
