Matrix Calculator
A free tool by DeepRit, a Google Ads agency that does PPC and nothing else. We build and run Google Ads accounts so every click is accounted for. Book a free audit call
Free matrix calculator. Find the determinant, inverse, transpose and trace of a matrix up to 6 × 6, and multiply two matrices. Type one row per line.
- Trace
- 0
- Size
- 0
Free, no sign-up. Runs in your browser: nothing you type is uploaded or saved.
How to use the matrix calculator
- Type matrix A, one row per line, with numbers separated by spaces or commas. For example:
2 1 01 3 10 1 4 - Type matrix B (optional) to multiply A × B.
- Read the results. For a square matrix, the matrix calculator shows the determinant, the trace, the inverse (if it exists) and the transpose. If you entered B, it shows the product A × B.
The calculator handles matrices up to 6 × 6, with decimals and negative numbers.
What is a matrix?
A matrix is a rectangular grid of numbers arranged in rows and columns. A matrix with m rows and n columns is called an m × n matrix. Matrices are used to represent systems of equations, transformations in graphics, data tables, networks and much more.
Determinant
The determinant is a single number calculated from a square matrix. It tells you whether the matrix can be inverted (a determinant of 0 means it can't) and how the matrix scales areas or volumes.
2 × 2 determinant
For [[a, b], [c, d]]: det = ad − bc.
[[1, 2], [3, 4]]: det = 1 × 4 − 2 × 3 = −2.
3 × 3 determinant
Expand along the first row:
det = a(ei − fh) − b(di − fg) + c(dh − eg)
for [[a, b, c], [d, e, f], [g, h, i]].
For [[2, 1, 0], [1, 3, 1], [0, 1, 4]]: 2(12 − 1) − 1(4 − 0) + 0 = 22 − 4 = 18.
For larger matrices, the matrix calculator uses row reduction (Gaussian elimination with partial pivoting), which is much faster and more accurate than expanding by hand.
Inverse
The inverse of a square matrix A, written A⁻¹, is the matrix such that A × A⁻¹ = I, the identity matrix (1s on the diagonal, 0s elsewhere). It exists only when the determinant isn't zero.
For a 2 × 2 matrix [[a, b], [c, d]]:
A⁻¹ = (1 ÷ det) × [[d, −b], [−c, a]]
For [[1, 2], [3, 4]]: A⁻¹ = (1 ÷ −2) × [[4, −2], [−3, 1]] = [[−2, 1], [1.5, −0.5]].
For larger matrices, the calculator uses Gauss–Jordan elimination. A matrix with no inverse is called singular.
Transpose
The transpose of A, written Aᵀ, swaps rows and columns: the first row becomes the first column, and so on. A 2 × 3 matrix becomes 3 × 2. Transposes are used in statistics (for example in least-squares regression), in geometry and in computing.
Trace
The trace is the sum of the numbers on the main diagonal (top-left to bottom-right) of a square matrix. For [[2, 1, 0], [1, 3, 1], [0, 1, 4]], the trace is 2 + 3 + 4 = 9. The trace equals the sum of the matrix's eigenvalues.
Matrix multiplication
To multiply A × B, the number of columns in A must equal the number of rows in B. Each entry of the product is the dot product of a row of A with a column of B.
For A = [[1, 2], [3, 4]] and B = [[5, 6], [7, 8]]:
- Top-left: 1 × 5 + 2 × 7 = 19
- Top-right: 1 × 6 + 2 × 8 = 22
- Bottom-left: 3 × 5 + 4 × 7 = 43
- Bottom-right: 3 × 6 + 4 × 8 = 50
So A × B = [[19, 22], [43, 50]].
Matrix multiplication is not commutative: A × B usually isn't equal to B × A.
Uses of matrices
- Solving systems of equations: a system Ax = b has the solution x = A⁻¹b when A is invertible. Our system of equations solver does this directly from equations.
- Computer graphics and games: rotating, scaling and moving objects uses matrix multiplication.
- Statistics and data science: regression, correlation matrices and machine learning.
- Economics: input–output models of industries.
- Engineering and physics: structures, circuits and quantum mechanics.
- Networks: adjacency matrices describe connections between points.
Rounding
Computers store decimals with limited precision, so results like 0.9999999999999998 can appear instead of 1. The matrix calculator rounds displayed values to about 10 significant figures and shows tiny values as 0, which removes most of this noise. For matrices with very large or very small entries, or matrices that are close to singular, results can still be sensitive to rounding.
A worked example
Sam runs a small workshop with two machines and makes two products. Each unit of product 1 needs 2 hours on machine 1 and 1 hour on machine 2; each unit of product 2 needs 1 hour on machine 1 and 3 hours on machine 2. Sam writes this as a matrix with one row per machine and one column per product:
M = [[2, 1], [1, 3]]
Next month's plan is 40 units of product 1 and 30 of product 2, written as a column: P = [[40], [30]].
Entering M as matrix A and P as matrix B, the matrix calculator gives M × P = [[110], [130]]: 110 hours on machine 1 and 130 hours on machine 2.
The determinant of M is 2 × 3 − 1 × 1 = 5, so M has an inverse, M⁻¹ = [[0.6, −0.2], [−0.2, 0.4]]. That lets Sam work backwards: if machine 1 has 120 hours available and machine 2 has 150, the plan that uses both fully is M⁻¹ × [[120], [150]] = [[42], [36]], so 42 units of product 1 and 36 of product 2.
Who uses a matrix calculator
Students use it for linear algebra, statistics and physics. Engineers and scientists use it for quick checks. Programmers use it for graphics and data work. Teachers use it to prepare examples with clean answers.
Need more customers from Google?
This tool is free and runs in your browser. If your business also needs more leads or sales, Google Ads is where people search with their wallet out. DeepRit is a Google Ads agency that does PPC and nothing else: we build the campaigns, block the searches that waste money, write the ads, set up conversion tracking and send you a short report every week. Request a free PPC audit and we will show you, in dollars, what we would fix first.
Matrix addition and scalar multiplication
Two matrices of the same size can be added by adding the numbers in matching positions. If A has 1 and 2 in its first row and B has 5 and 6 in its first row, the first row of A + B is 6 and 8. Subtraction works the same way. Multiplying a matrix by a single number, called a scalar, multiplies every entry: 3 times a matrix with first row 1 and 2 gives a first row of 3 and 6. These operations are simple, but they only work when the matrices are exactly the same size.
Why matrix multiplication isn't commutative
With ordinary numbers, 3 × 4 is the same as 4 × 3. With matrices, AB and BA are usually different, and one of them may not even exist. For AB to exist, the number of columns in A must equal the number of rows in B. A 2 × 3 matrix times a 3 × 2 matrix gives a 2 × 2 result, while the same two matrices multiplied the other way give a 3 × 3 result. Even for square matrices of the same size, AB and BA usually differ. This is one of the most common surprises for people new to matrices, and the matrix calculator lets you try both orders and see the difference for yourself.
The identity matrix
The identity matrix plays the role of the number 1. It has 1s along the main diagonal and 0s everywhere else. Multiplying any square matrix by the identity matrix of the same size leaves it unchanged. A matrix multiplied by its inverse gives the identity matrix, in either order. You can use this to check an inverse from the matrix calculator: multiply the original by the inverse and confirm you get 1s on the diagonal and 0s elsewhere, allowing for tiny rounding differences.
When a matrix has no inverse
A square matrix has an inverse only when its determinant isn't zero. A matrix with a determinant of zero is called singular. It squashes space into fewer dimensions, so information is lost and can't be recovered. For example, a 2 × 2 matrix whose second row is twice its first row has a determinant of zero, because its rows point in the same direction. In a system of equations, a singular coefficient matrix means there's no unique solution. The matrix calculator checks the determinant first and tells you when an inverse doesn't exist, instead of returning meaningless numbers.
Matrices in computer graphics
Every time a video game rotates a character or a design app scales an image, matrices do the work. A 2D rotation by an angle θ uses a 2 × 2 matrix with cos θ and −sin θ in the first row and sin θ and cos θ in the second. Multiplying each point's coordinates by that matrix rotates the shape. Combining several transformations, such as a rotation, then a scale, then another rotation, is done by multiplying their matrices together into one, which is much faster than applying each step separately to millions of points.
Sources and further reading
- Matrix (mathematics) on Wikipedia: definitions and operations.
- Determinant on Wikipedia: properties and methods of calculation.
- Invertible matrix on Wikipedia: when and how a matrix can be inverted.
Frequently asked questions
How do I find the determinant of a 2 × 2 matrix?
For [[a, b], [c, d]], the determinant is ad − bc.
When does a matrix have an inverse?
When it's square and its determinant isn't zero.
Can I multiply any two matrices?
Only if the number of columns in the first equals the number of rows in the second.
What is the transpose of a matrix?
The matrix with rows and columns swapped.
Is matrix multiplication commutative?
No. A × B is usually different from B × A.
Is the matrix calculator free?
Yes. It's free, needs no sign-up, and works in your browser.
Free PPC audit
See where your ad budget leaks.
We look at your Google Ads account before the call, then walk you through what we'd fix first, in dollars. No obligation, no hard sell.