Matrix Calculator
To multiply two matrices, multiply each row of the first by each column of the second and add the products. For [1 2; 3 4] times [5 6; 7 8], the top left entry is 1·5 + 2·7 = 19, and the whole product is [19 22; 43 50] (see each entry worked out). The calculator also adds, subtracts and transposes, and finds the determinant, inverse, power, rank and RREF of matrices up to 6 × 6, in exact fractions with every step.
Matrix calculator
Pick an operation, then type the entries or paste a whole matrix into any cell. Answers are exact fractions and update as you type.
The columns of A must equal the rows of B. Fractions such as 1/2 work, and you can paste a whole matrix into any cell.
Check your input
Cofactor expansion, one term at a time
Each entry of row 1 multiplies the determinant of what is left when its row and column are covered. The signs go +, −, +.
How to Use This Calculator
-
Pick the operation
Choose A + B, A × B, det A, A⁻¹ or another operation. Matrix B and the number field show up only when the operation needs them.
-
Enter the matrices
Set the rows and columns, then type the entries. You can also paste a whole matrix, copied from a worksheet or a spreadsheet, into any cell.
-
Read the answer and the steps
The answer appears in exact fractions. Click any entry of a product to see where it comes from, or step through the row operations.
What a matrix calculator does
A matrix is a grid of numbers in rows and columns. Its size is written rows × columns, so a 2 × 3 matrix has 2 rows and 3 columns. The entry in row i and column j is called aij. Each matrix operation needs matrices of certain sizes, and most mistakes in homework come from mixing those up. The table shows what each operation needs and what size the answer is.
| Operation | Needs | Answer |
|---|---|---|
| A + B, A − B | Same size, both m × n | m × n |
| AB | A is m × n, B is n × p | m × p |
| kA | Any matrix and a number k | Same size as A |
| Aᵀ | Any m × n matrix | n × m |
| det A | Square, n × n | One number |
| A⁻¹ | Square, and det A ≠ 0 | n × n |
| Aⁿ | Square (det A ≠ 0 for negative n) | n × n |
| Rank, RREF | Any m × n matrix | A number, or m × n |
Every answer here is exact. Decimals you type are read as fractions (0.5 becomes 1/2), and the arithmetic keeps fractions as fractions, so the inverse of [4 7; 2 6] starts with 3/5. If you need decimals, use the Decimals switch above the answer.
How to add and subtract matrices
Add or subtract the entries in the same position. Both matrices must be the same size. A 2 × 2 matrix and a 2 × 3 matrix cannot be added, because the third column has nothing to pair with.
Here 1 + 5 = 6, 2 + 6 = 8, 3 + 7 = 10 and 4 + 8 = 12. Subtraction works the same way, so A − B = [−4 −4; −4 −4]. Order matters for subtraction (B − A has the opposite signs) but not for addition.
How to multiply matrices
Matrix multiplication is not done entry by entry. Each entry of AB comes from a row of A and a column of B: multiply the first entry of the row by the first entry of the column, the second by the second, and so on, then add. This is called the dot product of the row and the column. Entry (i, j) of AB uses row i of A and column j of B.
- Row 1 of A times column 1 of B: 1·5 + 2·7 = 19.
- Row 1 of A times column 2 of B: 1·6 + 2·8 = 22.
- Row 2 of A times column 1 of B: 3·5 + 4·7 = 43.
- Row 2 of A times column 2 of B: 3·6 + 4·8 = 50.
When can you multiply two matrices?
The number of columns of A must equal the number of rows of B, because each row of A has to pair up with each column of B entry for entry. An m × n matrix times an n × p matrix gives an m × p matrix: the inner sizes must match, and the outer sizes give the answer. For example, a 2 × 3 matrix times a 3 × 2 matrix is 2 × 2:
The top left entry is 1·7 + 2·9 + 3·11 = 58. Multiply the same two matrices in the other order and you get a 3 × 3 matrix instead, starting with 7·1 + 8·4 = 39.
Show the 2 × 3 times 3 × 2 product
Order matters: AB is not BA
Even when both orders are defined, the answers usually differ. With the matrices above, AB = [19 22; 43 50] but BA = [23 34; 31 46]. The calculator shows BA under every product so you can compare. The identity matrix I (1s on the diagonal, 0s elsewhere) gives the same answer in both orders: AI = IA = A for any square A.
Multiplying by a number and transposing
Multiplying a matrix by a number k (scalar multiplication) multiplies every entry by k. So 3 · [1 2; 3 4] = [3 6; 9 12], and ½ · [1 2; 3 4] = [1/2 1; 3/2 2]. The size does not change.
The transpose Aᵀ turns rows into columns: row 1 of A becomes column 1 of Aᵀ. A 2 × 3 matrix becomes 3 × 2, so the transpose of [1 2 3; 4 5 6] is [1 4; 2 5; 3 6]. A matrix that equals its own transpose is called symmetric. Two rules come up often: (Aᵀ)ᵀ = A, and (AB)ᵀ = BᵀAᵀ, with the order reversed.
Show the transpose of a 2 × 3 matrix
How to find the determinant
The determinant is a single number worked out from a square matrix. It tells you whether the matrix has an inverse (only when det A ≠ 0), and its size is the factor by which the matrix scales areas or volumes.
2 × 2: ad − bc
For [a b; c d], multiply down the main diagonal and subtract the product of the other diagonal: det = ad − bc. For [4 7; 2 6] that is 4·6 − 7·2 = 10.
3 × 3: cofactor expansion
Go along the first row. Each entry is multiplied by the 2 × 2 determinant left when you cover its row and column (its minor), and the signs alternate +, −, +. For the matrix below:
- Cover row 1 and column 1: 2 · ((−1)·0 − 4·2) = 2 · (−8) = −16.
- Cover row 1 and column 2, and subtract: − 1 · (0·0 − 4·1) = − (−4) = 4.
- Cover row 1 and column 3: 3 · (0·2 − (−1)·1) = 3 · 1 = 3.
- Add them up: −16 + 4 + 3 = −9.
Show this determinant term by term
4 × 4 and larger: row reduction
Cofactor expansion gets slow fast: a 4 × 4 needs four 3 × 3 determinants. It is quicker to reduce the matrix to a triangle, with zeros below the diagonal, and multiply down the diagonal. Adding a multiple of one row to another does not change the determinant. Swapping two rows flips its sign, and dividing a row by a number divides the determinant by that number. The calculator uses this method from 4 × 4 up and lists each row operation.
A few facts help you check an answer. If a row or column is all zeros, det A = 0. If two rows are equal or one is a multiple of another, det A = 0. A triangular matrix has det A equal to the product of its diagonal. And det(AB) = det A · det B, while det(Aᵀ) = det A.
How to find the inverse of a matrix
The inverse A⁻¹ is the matrix that undoes A: A · A⁻¹ = A⁻¹ · A = I. Only a square matrix with a nonzero determinant has one.
The 2 × 2 shortcut
Swap a and d, change the signs of b and c, and divide everything by the determinant: [a b; c d]⁻¹ = (1/(ad − bc)) · [d −b; −c a]. For [4 7; 2 6] the determinant is 10, so:
Show the inverse of [4 7; 2 6]
3 × 3 and larger: Gauss-Jordan elimination
Write A and the identity side by side as [A | I]. Then use row operations to turn the left side into I: swap rows, divide a row by its pivot, and add multiples of one row to the others. Do every operation to the whole row, both sides of the bar. When the left side is I, the right side is A⁻¹. For A = [1 2 3; 0 1 4; 5 6 0], three rounds are enough:
The left side is now I, so A⁻¹ = [−24 18 5; 20 −15 −4; −5 4 1]. Every entry is a whole number because det A = 1. To check, multiply A by your answer: you should get I. If at some point a column has only zeros where the pivot should be, even after swapping rows, the matrix has no inverse.
When there is no inverse
A matrix with det A = 0 is called singular and has no inverse. [1 2; 2 4] is an example: its second row is twice the first, so 1·4 − 2·2 = 0. Row reduction shows the same thing as a row of zeros on the left of the bar. The calculator answers "None" in that case and shows where the reduction gets stuck.
Matrix powers
Aⁿ means A multiplied by itself n times, so it only works for square matrices. It is not the same as raising each entry to the power: [1 2; 3 4]² = [7 10; 15 22], not [1 4; 9 16]. A⁰ is the identity, and a negative power uses the inverse, A⁻² = (A⁻¹)².
A well-known example is the Fibonacci matrix. [1 1; 1 0]¹⁰ = [89 55; 55 34], and the numbers 89, 55 and 34 are Fibonacci numbers. The calculator works out large powers by repeated squaring (A², A⁴, A⁸, …), which takes far fewer products than multiplying one A at a time.
Show the Fibonacci matrix to the 10th power
Rank and RREF
The reduced row echelon form (RREF) is what is left after row reduction goes all the way. Every pivot is 1, it is the only nonzero entry in its column, and each pivot sits to the right of the one above. The rank is the number of pivots. It counts how many rows (or columns) are independent. [1 2 3; 2 4 6; 1 0 1] has rank 2, because its second row is twice the first.
Show the rank of this 3 × 3 matrix
Solving a system of equations with RREF
Write the coefficients and the right-hand sides of a system in one augmented matrix, one row per equation. Take this system:
Its augmented matrix is [1 1 1 6; 0 2 5 −4; 2 5 −1 27]. Reduce it to RREF and the left part becomes the identity, with the solution in the last column: x = 5, y = 3 and z = −2. Put the values back in to check: 5 + 3 + (−2) = 6. If a row comes out as [0 0 0 | 1], the system has no solution. If a column has no pivot, that variable is free and the system has infinitely many solutions.
Solve this system in the calculator
Common mistakes
- Multiplying entry by entry. That is only right for addition, subtraction and multiplying by a number. A product needs rows times columns.
- Swapping the order. AB and BA are different matrices, and only one of them may exist.
- Forgetting the minus sign in the middle of a 3 × 3 cofactor expansion. The signs go +, −, +.
- Doing a row operation to only one side of [A | I]. Both sides must change together.
- Squaring each entry for A². Matrix powers are repeated products.
- Looking for an inverse of a non-square matrix. Only square matrices with det A ≠ 0 have one.
Frequently Asked Questions
How do you multiply two matrices?
Multiply each row of the first matrix by each column of the second: multiply the matching entries and add them up. Row 1 of [1 2; 3 4] times column 1 of [5 6; 7 8] is 1 · 5 + 2 · 7 = 19, so 19 goes in row 1, column 1 of the answer. The full product is [19 22; 43 50].
Can you multiply a 2 × 3 matrix by a 3 × 2 matrix?
Yes. The first matrix has 3 columns and the second has 3 rows, so the product is defined, and it is 2 × 2. In the other order, a 3 × 2 times a 2 × 3 matrix is also defined, but the answer is 3 × 3. A 2 × 3 matrix times another 2 × 3 matrix is not defined.
How do you find the inverse of a 3 × 3 matrix?
Write the matrix and the identity side by side as [A | I], then use row operations until the left side is I. The right side is then A⁻¹. If a column runs out of nonzero pivots on the way, the determinant is 0 and there is no inverse. For [1 2 3; 0 1 4; 5 6 0] the inverse is [−24 18 5; 20 −15 −4; −5 4 1].
What does it mean if the determinant is 0?
The matrix is singular: it has no inverse, its rows (and columns) are not independent, and a system of equations with it has no single solution. [1 2; 2 4] has determinant 1 · 4 − 2 · 2 = 0 because its second row is twice the first.
Can you divide matrices?
Not directly. Matrix division is not defined. Instead you multiply by an inverse: to "divide" A by B you work out AB⁻¹ (or B⁻¹A, which is usually different). That only works when B is square and its determinant is not 0.
Is AB the same as BA?
Usually not. Matrix multiplication is not commutative. For A = [1 2; 3 4] and B = [5 6; 7 8], AB = [19 22; 43 50] but BA = [23 34; 31 46]. Sometimes BA is not even defined when AB is.
What is RREF used for?
The reduced row echelon form solves systems of linear equations and shows the rank. Put the coefficients and the right-hand sides in one augmented matrix and reduce it. Each pivot row then reads off one variable, and a column without a pivot is a free variable.