Algebra
Matrix Calculator: Add, Multiply, Invert And Find Determinants
Last updated: October 2026
A matrix calculator performs operations on grids of numbers called matrices. It can add and multiply matrices, find the transpose, determinant and inverse, reduce to RREF, and solve systems of equations. For example, the 2×2 matrix [[1, 2], [3, 4]] has a determinant of 1 × 4 − 2 × 3 = −2.
- Free, no sign-up
- Shows the working
- Runs on your device
Matrices can look intimidating, but every operation follows a few simple rules. This guide explains what a matrix is, how to use the matrix calculator above, and how to do each operation by hand with a worked example. It also covers solving systems of equations, eigenvalues, and how to work with matrices in Excel and Python. Every example was checked in Python.
What Is A Matrix?
A matrix is a rectangular grid of numbers arranged in rows and columns. Its size is written as rows × columns, so a matrix with 2 rows and 3 columns is a 2×3 matrix (read "2 by 3").
Each number in the matrix is an entry or element. The entry in row i and column j is written aᵢⱼ. In the matrix A = [[1, 2], [3, 4]], the entry a₂₁ is 3, because it sits in row 2, column 1.
In this guide, matrices are written row by row inside brackets. So [[1, 2], [3, 4]] means:
| Column 1 | Column 2 | |
|---|---|---|
| Row 1 | 1 | 2 |
| Row 2 | 3 | 4 |
Common Types Of Matrices
Some matrices have special shapes or patterns, and many operations depend on knowing which type you have.
| Type | What it looks like | Example |
|---|---|---|
| Square | Same number of rows and columns | 3×3 |
| Row matrix | One row | [[1, 5, 2]] |
| Column matrix (vector) | One column | [[4], [7]] |
| Zero matrix | Every entry is 0 | [[0, 0], [0, 0]] |
| Identity matrix (I) | 1s on the main diagonal, 0s elsewhere | [[1, 0], [0, 1]] |
| Diagonal | Nonzero entries only on the main diagonal | [[3, 0], [0, 5]] |
| Symmetric | Equal to its own transpose | [[2, 7], [7, 1]] |
The identity matrix works like the number 1. Multiplying any matrix by I leaves it unchanged, so AI = IA = A.
How To Use The Matrix Calculator
The matrix calculator above has three tabs, and every answer shows its steps.
- Two-Matrix Operations: set the size of matrices A and B, type the entries, and choose an operation: add, subtract, multiply, scalar multiply, power or transpose.
- Single Matrix: enter one matrix to find its determinant, inverse, rank, row echelon form, RREF, trace or eigenvalues.
- Solve a System: type the coefficients of your linear equations, and the tool builds the augmented matrix and solves it.
You can type whole numbers, decimals, negatives and fractions like 3/4. Answers stay as exact fractions unless you switch to decimals.
Matrix Addition And Subtraction
To add or subtract two matrices, add or subtract the entries in matching positions. Both matrices must be the same size.
Example: A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]]
- A + B = [[1 + 5, 2 + 6], [3 + 7, 4 + 8]] = [[6, 8], [10, 12]]
- A − B = [[1 − 5, 2 − 6], [3 − 7, 4 − 8]] = [[−4, −4], [−4, −4]]
Addition is commutative, so A + B = B + A. Subtraction is not, since B − A gives the opposite signs. You cannot add a 2×2 matrix to a 2×3 matrix, because some entries would have no partner.
Scalar Multiplication
To multiply a matrix by a single number, called a scalar, multiply every entry by that number.
Example: 3A = [[3 × 1, 3 × 2], [3 × 3, 3 × 4]] = [[3, 6], [9, 12]]
Scalar multiplication works on a matrix of any size. Multiplying by −1 flips every sign, and multiplying by 0 gives the zero matrix.
Matrix Multiplication
To multiply two matrices, multiply each row of the first matrix by each column of the second, then add the products. The number of columns in the first matrix must equal the number of rows in the second.
The size rule: an m×n matrix times an n×p matrix gives an m×p matrix. The inside numbers (n and n) must match, and the outside numbers give the size of the answer.
| A size | B size | Can you multiply A × B? | Result size |
|---|---|---|---|
| 2×2 | 2×2 | Yes | 2×2 |
| 2×3 | 3×2 | Yes | 2×2 |
| 3×2 | 2×4 | Yes | 3×4 |
| 2×3 | 2×3 | No (3 ≠ 2) | None |
Example: A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]]
- 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.
- So AB = [[19, 22], [43, 50]].
Order matters. Multiplying in the other order gives BA = [[23, 34], [31, 46]], a different answer. Matrix multiplication is not commutative, so AB and BA are usually not equal. Sometimes only one order is even possible.
Example with different sizes: a 2×3 matrix [[2, 3, 1], [4, 1, 0]] times a 3×2 matrix [[1, 2], [0, 1], [5, 3]] gives a 2×2 result, [[7, 10], [4, 9]]. The first entry is (2 × 1) + (3 × 0) + (1 × 5) = 7.
Matrix Powers
A matrix power means multiplying a square matrix by itself. A² = A × A, A³ = A × A × A, and so on.
Example: A² for A = [[1, 2], [3, 4]] is A × A = [[7, 10], [15, 22]].
Two things to watch:
- Only square matrices have powers, because a 2×3 matrix cannot be multiplied by another 2×3 matrix.
- Do not square each entry. Squaring the entries of A gives [[1, 4], [9, 16]], which is not A². You must use full matrix multiplication.
By definition, A⁰ = I, the identity matrix. A⁻¹ is the inverse, covered below.
Transpose Of A Matrix
The transpose flips a matrix over its main diagonal, so rows become columns and columns become rows. It is written Aᵀ.
Example: the transpose of A = [[1, 2], [3, 4]] is Aᵀ = [[1, 3], [2, 4]].
A 2×3 matrix becomes a 3×2 matrix when transposed. Transposing twice brings you back to the original, so (Aᵀ)ᵀ = A. One useful rule: the transpose of a product reverses the order, so (AB)ᵀ = BᵀAᵀ. A matrix equal to its own transpose is called symmetric.
Determinant Of A Matrix
The determinant is a single number calculated from a square matrix. It tells you whether the matrix has an inverse: if the determinant is 0, there is no inverse. It is written det(A) or |A|.
The determinant also has a geometric meaning. For a 2×2 matrix, its absolute value is how much the matrix stretches the area of a shape. A determinant of 0 means the matrix squashes everything flat onto a line or a point.
2×2 Determinant
For a 2×2 matrix [[a, b], [c, d]], the determinant is ad − bc. Multiply down the main diagonal, then subtract the product of the other diagonal.
| Matrix | Calculation | Determinant |
|---|---|---|
| [[1, 2], [3, 4]] | (1 × 4) − (2 × 3) | −2 |
| [[3, 8], [4, 6]] | (3 × 6) − (8 × 4) | −14 |
| [[6, 2], [3, 1]] | (6 × 1) − (2 × 3) | 0 |
The last matrix has a determinant of 0, so it has no inverse. Notice that its second row is exactly half of the first row. When one row is a multiple of another, the determinant is always 0.
3×3 Determinant
For a 3×3 matrix, expand along the first row. Multiply each entry by the 2×2 determinant left after crossing out its row and column, and alternate the signs +, −, +.
Example: C = [[2, −1, 0], [1, 3, 2], [0, 1, 4]]
- First entry, 2: cross out row 1 and column 1 to get [[3, 2], [1, 4]]. Its determinant is (3 × 4) − (2 × 1) = 10. Term: +2 × 10 = 20.
- Second entry, −1: cross out row 1 and column 2 to get [[1, 2], [0, 4]]. Its determinant is 4. Term: −(−1) × 4 = 4.
- Third entry, 0: the term is 0, no matter what is left.
- Add the terms: 20 + 4 + 0 = 24.
Shortcut: expand along the row or column with the most zeros, since each zero removes a whole term. For larger matrices, row reduction to a triangular form is faster. The determinant of a triangular matrix is just the product of its diagonal entries.
Inverse Of A Matrix
The inverse of a square matrix A, written A⁻¹, is the matrix that gives the identity when multiplied by A: A × A⁻¹ = I. Only square matrices with a nonzero determinant have an inverse. A matrix with no inverse is called singular.
2×2 Inverse Formula
For A = [[a, b], [c, d]], swap a and d, change the signs of b and c, and divide everything by the determinant:
A⁻¹ = (1 ÷ (ad − bc)) × [[d, −b], [−c, a]]
Example: A = [[1, 2], [3, 4]], with det A = −2.
- Swap and change signs: [[4, −2], [−3, 1]].
- Divide each entry by −2: A⁻¹ = [[−2, 1], [3/2, −1/2]].
- Check: A × A⁻¹ = [[1, 0], [0, 1]]. ✔
Inverses often contain fractions, so keeping exact values matters. The fraction calculator helps when you simplify entries by hand.
Inverse Of A 3×3 Matrix With Gauss-Jordan
For a 3×3 or larger matrix, the Gauss-Jordan method is the most reliable way by hand.
- Write the matrix next to the identity matrix, as [A | I].
- Use row operations to turn the left side into I.
- Whatever the right side becomes is A⁻¹.
For C = [[2, −1, 0], [1, 3, 2], [0, 1, 4]], this gives C⁻¹ = [[5/12, 1/6, −1/12], [−1/6, 1/3, −1/6], [1/24, −1/12, 7/24]]. The calculator shows every row operation along the way, which is the part most students need to check.
Row Echelon Form, RREF And Rank
Row reduction rewrites a matrix into a simpler form using three allowed row operations. These forms reveal the rank of a matrix and the solutions of a system.
The three row operations are:
- Swap two rows.
- Multiply a row by a nonzero number.
- Add a multiple of one row to another row.
Row echelon form (REF) has all zero rows at the bottom, and each row's first nonzero entry (its pivot) sits to the right of the pivot above it. Reduced row echelon form (RREF) goes further: every pivot is 1, and each pivot is the only nonzero entry in its column.
Example: M = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] reduces to the RREF [[1, 0, −1], [0, 1, 2], [0, 0, 0]].
The rank is the number of nonzero rows in the echelon form. Here the rank is 2, not 3, because the third row became all zeros. That also means det M = 0. A square matrix has an inverse only when its rank equals its size.
Solving Systems Of Equations With Matrices
A system of linear equations can be written as one matrix equation, Ax = b. A holds the coefficients, x holds the unknowns, and b holds the constants. There are three common ways to solve it.
Example system:
- 2x + y = 5
- x − y = 1
Method 1: inverse matrix. If A = [[2, 1], [1, −1]] and b = [[5], [1]], then x = A⁻¹b. Since det A = −3, the inverse exists, and A⁻¹b = [[2], [1]]. So x = 2 and y = 1.
Method 2: row reduction. Write the augmented matrix [[2, 1 | 5], [1, −1 | 1]] and reduce it to RREF: [[1, 0 | 2], [0, 1 | 1]]. Read the answers straight from the last column.
Method 3: Cramer's rule. Replace one column of A with b and divide determinants. For x, the determinant of [[5, 1], [1, −1]] is −6, and −6 ÷ −3 = 2. For y, the determinant of [[2, 5], [1, 1]] is −3, and −3 ÷ −3 = 1.
A 3-variable example: for x + y + z = 6, 2x − y + z = 3 and x + 2y − z = 2, the coefficient matrix has a determinant of 7, so there is exactly one solution: (1, 2, 3).
When the determinant is 0, the system has either no solution (the equations contradict each other) or infinitely many solutions (some equations repeat information). Row reduction tells you which: a row like [0, 0 | 5] means no solution, and a row of all zeros means infinitely many.
Eigenvalues And Eigenvectors
An eigenvector of a square matrix is a nonzero vector that the matrix only stretches or shrinks, without turning it. The stretch factor is the eigenvalue, written λ. In symbols, Av = λv.
To find the eigenvalues of a 2×2 matrix, solve det(A − λI) = 0.
Example: A = [[4, 1], [2, 3]]
- Subtract λ from the diagonal: [[4 − λ, 1], [2, 3 − λ]].
- Take the determinant: (4 − λ)(3 − λ) − 2 = λ² − 7λ + 10.
- Set it to 0 and factor: (λ − 5)(λ − 2) = 0.
- The eigenvalues are λ = 5 and λ = 2.
For λ = 5, an eigenvector is [[1], [1]], since A × [[1], [1]] = [[5], [5]]. For a 2×2 matrix, step 3 is always a quadratic, so the quadratic equation solver can finish it when it does not factor neatly.
Two quick checks: the eigenvalues add up to the trace (4 + 3 = 7) and multiply to the determinant (4 × 3 − 1 × 2 = 10).
Where Matrices Are Used
Matrices are the standard way to store and transform many numbers at once. That makes them central to computing, science and economics.
- Computer graphics and games: rotating, scaling and moving shapes are all matrix multiplications. The matrix [[0, −1], [1, 0]] rotates a point 90° counterclockwise, so (3, 1) moves to (−1, 3).
- Data and statistics: a spreadsheet of data is a matrix, and tools like regression and covariance matrices work on it directly. The statistics calculator covers the averages and spread behind those methods.
- Machine learning: neural networks store their weights in matrices and process data with huge numbers of matrix multiplications.
- Engineering and physics: circuits, structures and vibrations lead to large systems of equations solved with matrices.
- Probability: Markov chains use a transition matrix to model how something moves between states, such as weather patterns or customer behavior.
- Economics: input-output models describe how industries depend on each other's products using a matrix of coefficients.
Matrices On Calculators, Excel And Python
You can work with matrices on a graphing calculator, in a spreadsheet or in code. Each tool has its own commands.
| Tool | Multiply | Inverse | Determinant | Transpose |
|---|---|---|---|---|
| TI-84 (MATRIX menu: 2nd, then x⁻¹) | [A]*[B] | [A]⁻¹ | det([A]) | [A]ᵀ |
| Excel, Google Sheets | =MMULT(A, B) | =MINVERSE(A) | =MDETERM(A) | =TRANSPOSE(A) |
| Python (NumPy) | A @ B | np.linalg.inv(A) | np.linalg.det(A) | A.T |
Practical tips:
- In Excel, the * operator multiplies entry by entry, not as matrices. Use MMULT for true matrix multiplication.
- In Python, A * B on NumPy arrays also multiplies entry by entry. Use A @ B instead.
- To solve Ax = b in code, np.linalg.solve(A, b) is faster and more accurate than computing the inverse first.
- Expect tiny rounding errors. Software that uses decimals may show a determinant of 6.66e-16 instead of 0. Treat values that small as zero.
Common Matrix Mistakes
Most matrix errors come from mismatched sizes, treating matrix multiplication like regular multiplication, and sign slips.
| Mistake | Example | Fix |
|---|---|---|
| Multiplying entry by entry | AB = [[5, 12], [21, 32]] | Use rows times columns: [[19, 22], [43, 50]] |
| Assuming AB = BA | Swapping the order | Keep the order as written |
| Ignoring the size rule | Multiplying 2×3 by 2×3 | Columns of A must equal rows of B |
| Squaring each entry for A² | A² = [[1, 4], [9, 16]] | A² = A × A = [[7, 10], [15, 22]] |
| Mixing up the 2×2 inverse signs | Changing the signs of a and d | Swap a and d, negate b and c |
| Inverting a singular matrix | Trying to invert [[6, 2], [3, 1]] | Check the determinant first. If it is 0, there is no inverse |
| Dividing matrices | Writing A ÷ B | Multiply by the inverse: A × B⁻¹ |
Summary
- A matrix is a grid of numbers sized rows × columns.
- Add and subtract entry by entry, and only with the same size.
- Multiply rows by columns. The inner sizes must match, and the order matters.
- The 2×2 determinant is ad − bc. If the determinant is 0, there is no inverse.
- Use the inverse, row reduction or Cramer's rule to solve Ax = b.
- Eigenvalues solve det(A − λI) = 0.
Next step: enter your matrices in the matrix calculator at the top of this page, or browse more math tools on the Calc Solver homepage.
Frequently Asked Questions
Can you divide two matrices?
Not directly. There is no matrix division operation. Instead, you multiply by the inverse. To "divide" A by B, compute A × B⁻¹ or B⁻¹ × A, and the two usually give different answers because order matters. This only works when B is square and has a nonzero determinant. If B has no inverse, the division has no meaning.
What is the trace of a matrix?
The trace is the sum of the entries on the main diagonal of a square matrix. For [[1, 2], [3, 4]], the trace is 1 + 4 = 5. The trace also equals the sum of the matrix's eigenvalues, which makes it a fast check when you find eigenvalues by hand. Like the determinant, it is only defined for square matrices.
What does a determinant of 0 mean?
A determinant of 0 means the matrix is singular. It has no inverse, its rows (and columns) depend on each other, and its rank is less than its size. Geometrically, the matrix flattens space into a lower dimension, like squashing a square into a line. If the matrix comes from a system of equations, the system has no solution or infinitely many.
Is a vector a matrix?
Yes. A vector is a matrix with one row or one column. A column vector like [[3], [5]] is a 2×1 matrix, and a row vector like [[3, 5]] is a 1×2 matrix. Matrix rules apply to vectors too, so multiplying a 2×2 matrix by a 2×1 vector gives another 2×1 vector. This is how matrices move points in graphics.
How big can a matrix be?
There is no size limit in math. A matrix can have any number of rows and columns. In practice, hand calculations get slow past 3×3 or 4×4, which is why calculators help. Computers routinely handle matrices with thousands or even millions of rows, such as large data sets or the weight matrices inside machine learning models.
What is the difference between REF and RREF?
Both are simplified forms from row reduction. In row echelon form (REF), zero rows sit at the bottom and each pivot is to the right of the one above, but pivots can be any nonzero number. Reduced row echelon form (RREF) also requires every pivot to be 1 and to be the only nonzero entry in its column. A matrix has many REFs but only one RREF.
Try it with your own numbers
Use a free CalcSolver tool to check the examples in this guide.