Matrix Calculator
Last updated:
Enter your matrix values and instantly calculate addition, subtraction, multiplication, determinant, inverse, transpose, trace, powers, and more with clear step-by-step results.
Matrix A: 3×3 · Matrix B: 3×3
Have another calculation?
Ask AI and continue with a different calculation without searching for a tool.
Was this calculator helpful?
Your feedback helps us improve our calculators.
What Is a Matrix Calculator?
A matrix calculator performs the standard linear algebra operations on one or two matrices: addition, subtraction, multiplication, determinant, inverse, transpose, trace, power, scalar multiplication, row echelon form, and LU decomposition. Pick the operation, set the dimensions, type the entries, and hit Calculate. The result panel shows the answer along with its dimensions, determinant, trace, rank, and whether the matrix is invertible, so you can check homework line by line instead of just comparing a final number.
How to Use the Matrix Calculator
Pick the operation: Add, Subtract, Multiply, Det(A), Inverse, Transpose, Trace, Power, Multiply by (scalar), Row echelon or LU decomposition. The form adjusts: single-matrix operations hide Matrix B.
Set the dimensions: Rows and columns for A, and for B where the operation needs two matrices. Default is 3×3. Check the rules table below before you type anything; a 2×3 times a 2×3 will fail at the Calculate button, not before.
Enter the entries: Tab moves across a row. Negative numbers and decimals are fine. Leave a cell blank, and it's read as 0, which is the most common source of "my determinant is wrong" (a blank you didn't notice).
Calculate: The result panel shows the answer plus dimensions, determinant, trace, rank, and invertibility, and the working for each entry. Clear resets both matrices.
Matrix Dimensions Explained
A matrix's dimensions are written rows × columns, always in that order. A 2×3 matrix has 2 rows and 3 columns:
[ 1 2 3 ]
[ 4 5 6 ]
Entry a₂₃ is row 2, column 3, which is 6. Entry a₃₂ doesn't exist; there's no row 3. A matrix with the same number of rows and columns (2×2, 3×3, n×n) is square, and several operations only make sense for square matrices, because they need a main diagonal to work with.
The dimension is the first thing the calculator checks, and the reason is in the next table.
Matrix Operation Rules
Most "the calculator gave me an error" moments come from the shape of the matrix, not the numbers in it. This table is the whole rulebook:
Operation | Needs | Result |
Add / Subtract | A and B the same size | Same size |
Multiply (AB) | Columns of A = rows of B | Rows of A × columns of B |
Determinant | Square matrix | A single number |
Inverse | Square, determinant ≠ 0 | Same size |
Transpose | Any matrix | Rows and columns swapped |
Trace | Square matrix | A single number |
Power (Aⁿ) | Square matrix | Same size |
Scalar multiply | Any matrix | Same size |
Row echelon | Any matrix | Same size |
LU decomposition | Square matrix | Two triangular matrices |
"Square" appears five times in that table. If your matrix isn't square, you're limited to add, subtract, multiply, transpose, scalar and row echelon form.
Matrix Addition
Matrix addition combines two matrices by adding elements in matching positions.
If:
A=[aij]
and:
B=[bij]
then:
C=A+B
where:
cij=aij+bij
The two matrices must have identical dimensions.
For example:
[2435]+[1267]=[36912]
Each entry in Matrix A is simply added to the entry in the same position in Matrix B.
A matrix addition calculator is especially helpful with larger matrices, where performing every element-wise calculation manually can become repetitive.
Matrix Subtraction
Matrix subtraction follows the same compatibility rule as addition: both matrices must have the same dimensions.
The formula is:
C=A−B
For each corresponding element:
cij=aij−bij
For example:
[8659][3124][5535]
Subtracting matrices of different dimensions is not defined because their elements cannot be matched position by position.
Matrix Multiplication
Matrix multiplication combines two matrices row by column. It's defined only when the number of columns in A equals the number of rows in B: an m×n matrix times an n×p matrix gives an m×p matrix. Each entry of the result is a row of A dotted with a column of B.
Take A=[1324] and B=[5768]
Row 1 of A · column 1 of B: 1×5 + 2×7 = 19
Row 1 · column 2: 1×6 + 2×8 = 22
Row 2 · column 1: 3×5 + 4×7 = 43
Row 2 · column 2: 3×6 + 4×8 = 50
AB=[19432250]. Four dot products for a 2×2. A 3×3 needs nine, each with three terms. A 5×5 needs 25, each with five. That's 125 multiplications, which is the point at which most people stop doing it by hand and start using a matrix multiplication calculator.
The dimension check in one line: (3×2)(2×4) works and gives 3×4, because the inner 2s match. (3×2)(3×4) fails, because 2 ≠ 3. If the row-times-column idea still feels arbitrary, Khan Academy's matrix multiplication unit explains where the rule comes from in about ten minutes.
Determinant of a 3×3 Matrix
For a 2×2 matrix [a,b;c,d], the determinant is ad − bc. Everyone knows that one. The 3×3 is where people get lost, so here it is in full.
Take A = [1,2,3; 0,1,4; 5,6,0]. Expand along the first row. Each entry gets multiplied by the determinant of the 2×2 that's left when you delete its row and column, with alternating signs (+, −, +):
First entry, 1: delete row 1 and column 1, leaving 1640. Its determinant is 1×0 − 4×6 = −24. Contribution: +1 × (−24) = −24
Second entry, 2: delete row 1 and column 2, leaving 0540. Determinant 0×0 − 4×5 = −20. Contribution: −2 × (−20) = +40
Third entry, 3: delete row 1 and column 3, leaving 0516. Determinant 0×6 − 1×5 = −5. Contribution: +3 × (−5) = −15
det(A) = −24 + 40 − 15 = 1.
The 2×2 determinants in steps 1–3 are called minors. A minor with its sign attached is a cofactor. You'll need those words again for the inverse.
Quick check with the Rule of Sarrus (3×3 only): sum the three down-right diagonals, subtract the three down-left ones. Down-right: 1×1×0 + 2×4×5 + 3×0×6 = 0 + 40 + 0 = 40. Down-left: 3×1×5 + 1×4×6 + 2×0×0 = 15 + 24 + 0 = 39. 40 − 39 = 1. Matches.
Sarrus doesn't work for 4×4 and up. Cofactor expansion does, but a 4×4 by hand is four 3×3 determinants, and that's a calculator job.
Inverse of a 3×3 Matrix
A square matrix has an inverse when its determinant is not zero. A × A⁻¹ = I, the identity matrix. For 2×2, the formula is A−1=ad−bc1[d−c−ba]. For 3×3, the method is cofactors again.
Same A=105216340,det(A)=1 from above.
Step 1: compute all nine cofactors. Each is the 2×2 minor with the sign from the checkerboard pattern [+,−,+; −,+,−; +,−,+].
Position | Minor | Signed cofactor |
(1,1) | 1640=−24 | −24 |
(1,2) | 0540=−20 | +20 |
(1,3) | 0516=−5 | −5 |
(2,1) | 2630=−18 | +18 |
(2,2) | 1530=−15 | −15 |
(2,3) | 1526=−4 | +4 |
(3,1) | 2134=5 | +5 |
(3,2) | 1034=4 | −4 |
(3,3) | 1021=1 | +1 |
Cofactor Matrix=−2418520−15−4−541
Step 2: Transpose it. This is the adj(A)=−2420−518−1545−41
Step 3: divide by the determinant. det(A) = 1, so A−1=adj(A)=−2420−518−1545−41
Check: row 1 of A times column 1 of A⁻¹ is 1×(−24) + 2×20 + 3×(−5) = −24 + 40 − 15 = 1. Row 1 times column 2: 1×18 + 2×(−15) + 3×4 = 0. The identity matrix is coming out. (We chose this A because its determinant is 1, so the inverse has no fractions. Real-world matrices are rarely that kind.)
Nine 2×2 determinants, a transpose, and a division. By the time you're doing this for a 4×4 (sixteen 3×3 determinants), the calculator isn't cheating, it's sanity.
Matrix Transpose
The transpose switches the rows and columns of a matrix.
It is written as:
AT
Mathematically:
(AT)ij=Aji
Suppose:
A=[142536]
Then:
AT=123456
Notice that the first row of (A) becomes the first column of (AT).
If the original matrix is:
m×n
its transpose has dimensions:
n×m
Unlike determinants, inverses, and traces, a matrix does not need to be square to be transposed.
Matrix Trace
The trace of a square matrix is the sum of all elements on its main diagonal, running from the upper-left to the lower-right.
For an (n×n) matrix:
tr(A)=∑i=1naii
For example:
A=236458179
The main diagonal contains:
2,;5,;9
Therefore:
tr(A)=2+5+9=16
The trace is defined for square matrices and should not be confused with the determinant. Both produce a single number, but they are calculated differently and represent different matrix properties.
Matrix Power
A matrix power means multiplying a square matrix by itself repeatedly.
For a positive integer (n):
An=n timesA×A×⋯×A
For example:
A2=A×A
and:
A3=A×A×A
This is important: matrix powers do not normally mean raising each individual matrix element to the exponent.
For example, if:
A=[1023]
then:
A2=[1023][1023]
which gives:
A2=[1089]
The calculator's Power option lets you provide the matrix and select the exponent before calculating the resulting matrix.
Scalar Multiplication - Multiply a Matrix by a Number
Scalar multiplication multiplies every element of a matrix by the same number.
If (k) is a scalar and:
A=[aij]
then:
kA=[kaij]
For example, let:
A=[1234]
and:
k=2
Then:
2A=[2(1)2(2)2(3)2(4)]=[2468]
This differs from matrix multiplication, which uses two matrices and follows the row-by-column multiplication rule.
Row Echelon Form
Row echelon form is a simplified version of a matrix created using elementary row operations. It is commonly used in linear algebra to solve systems of equations, identify pivot positions, and determine the rank of a matrix.
A matrix is in row echelon form when:
All nonzero rows appear above any rows containing only zeros.
The leading nonzero entry, or pivot, of each row is farther to the right than the pivot in the row above it.
All entries below each pivot are zero.
The three elementary row operations are:
1. Swap Two Rows
Two rows can exchange positions:
Ri↔Rj
2. Multiply a Row by a Nonzero Number
Ri→kRi,k=0
3. Add a Multiple of One Row to Another
Ri→Ri+kRj
These operations change the form of the matrix while preserving the relationships needed for solving the associated linear system.
For example, elimination may transform:
A=100250007
into a row echelon form. In this example, the matrix is already in row echelon form because each pivot moves to the right and all entries below the pivots are zero.
The calculator's Row echelon option performs the required elimination and can also display information such as the resulting matrix, matrix size, rank, and determinant when applicable.
Row Echelon Form vs. Reduced Row Echelon Form
These two terms should not be confused.
In row echelon form (REF), entries below each pivot are zero. In reduced row echelon form (RREF), each pivot is additionally equal to 1 and is the only nonzero entry in its column.
The calculator option shown here is Row echelon, so results should be interpreted as row echelon form rather than automatically assuming reduced row echelon form.
LU Decomposition
LU decomposition factors a matrix into two triangular matrices:
A=LU
where:
L=lower triangular matrix
and:
U=upper triangular matrix
A lower triangular matrix generally has zeros above its main diagonal:
L=l11l21l310l22l3200l33
An upper triangular matrix has zeros below its main diagonal:
U=u1100u12u220u13u23u33
The goal is to find (L) and (U) such that multiplying them reconstructs the original matrix:
LU=A
During elimination, (U) contains the values left after eliminating entries below the pivots, while (L) records the multipliers used during that process.
LU decomposition is useful for solving linear systems and for computations where the same coefficient matrix is used repeatedly.
Depending on the matrix, row exchanges or pivoting may be necessary. Therefore, not every matrix has a straightforward (A=LU) factorization without additional permutation information.
How to Solve Matrices: Row Echelon Form and Systems of Equations
People who search "how to solve matrices" usually mean one of two things. Either they want a single operation (determinant, inverse, product), which is any button above, or they want to solve a system of linear equations, which is what row echelon form is for. This section covers the second, because it's the one textbooks make look harder than it is.
Take the system:
2x + y − z = 8
−3x − y + 2z = −11
−2x + y + 2z = −3
Write it as an augmented matrix, coefficients on the left, constants on the right:
[ 2 1 −1 | 8 ]
[ −3 −1 2 | −11 ]
[ −2 1 2 | −3 ]
Now use the three elementary row operations (swap two rows; multiply a row by a nonzero number; add a multiple of one row to another) to get zeros below the diagonal.
R2 ← R2 + 1.5·R1 → [0, 0.5, 0.5 | 1]
R3 ← R3 + R1 → [0, 2, 1 | 5]
R3 ← R3 − 4·R2 → [0, 0, −1 | 1]
The matrix is now in row echelon form:
[ 2 1 −1 | 8 ]
[ 0 0.5 0.5 | 1 ]
[ 0 0 −1 | 1 ]
Read it bottom up. Row 3: −z = 1, so z = −1. Row 2: 0.5y + 0.5(−1) = 1, so y = 3. Row 1: 2x + 3 + 1 = 8, so x = 2.
Notice the 0.5s. Step 1 introduced them, and by step 3 you're tracking fractions. This is why the calculator's row echelon output shows decimals; if your textbook shows fractions, they're the same numbers. Use the fraction calculator to convert if you need to match a printed answer exactly.
Row echelon vs reduced row echelon. Row echelon form (what this tool produces) has zeros below the pivots. Reduced row echelon form (RREF, Gauss–Jordan) goes further: every pivot is 1 and every entry above a pivot is also 0, so the solution can be read straight off without back-substitution. RREF is more work by hand and gives the same answer. Gilbert Strang's MIT 18.06 lecture on elimination is the clearest 45 minutes on why this works, if you want the reasoning rather than the recipe.
Rank is the number of nonzero rows once you're in row echelon form. Here it's 3, which for a 3×3 means the matrix is invertible and the system has exactly one solution. Rank 2 would mean either infinitely many solutions or none, depending on the right-hand side. The calculator reports rank in the result panel for every input.
Matrix Multiplication vs. Scalar Multiplication
Although both operations involve multiplication, they work differently.
Matrix Multiplication | Scalar Multiplication |
Usually involves two matrices | Involves one matrix and one scalar |
Uses row-by-column calculations | Multiplies every element by the same number |
Requires compatible matrix dimensions | Does not require a second matrix |
Written as (AB) | Written as (kA) |
Can change the dimensions of the result | Keeps the original matrix dimensions |
For matrix multiplication:
cij=∑k=1naikbkj
For scalar multiplication:
(kA)ij=kaij
Keeping this distinction clear prevents one of the most common mistakes in matrix calculations.
LU Decomposition
LU decomposition factors a square matrix into a lower-triangular L (zeros above the diagonal, ones on it) and an upper-triangular U (zeros below), with A = LU. U is what row reduction produces; L records the multipliers you used to get there. In the example above, the multipliers were −1.5, −1 and 4, and those (with signs flipped) are exactly what fills L below the diagonal.
Why bother? Once you have L and U, solving Ax = b for a new b is two quick triangular solves instead of a full elimination. Numerical libraries do this under the hood: NumPy's linalg.solve calls LAPACK's gesv, which is LU with partial pivoting.
One catch: some matrices need a row swap before elimination can proceed (any matrix with a 0 in the top-left corner, for a start). Then the factorisation is PA = LU with a permutation matrix P. If the calculator can't factor your matrix as a plain A = LU, that's why; swap two rows and try again.
Transpose, Trace, Power and Scalar Multiplication
Transpose swaps rows and columns: [1,2,3;4,5,6]ᵀ = [1,4;2,5;3,6]. An m×n becomes n×m. Works on any matrix. Shows up constantly in statistics (the statistics calculator is doing XᵀX behind the scenes for regression).
Trace is the sum of the main diagonal of a square matrix. Equals the sum of the eigenvalues, which is the main reason anyone cares. If you're computing traces for a probability or statistics problem (covariance matrices, say), the trace is the total variance.
Power Aⁿ is A multiplied by itself n times. Square matrices only. A² = A×A, not "square each entry"; see the mistakes section. (For ordinary numbers, the exponent calculator is the right tool; this one is for matrices.) Powers of a transition matrix are how Markov chains are computed, which is how Google's original PageRank worked.
Scalar multiplication multiplies every entry by one number: 2 × [1,3;2,4] = [2,6;4,8]. No dimension rules. It's the only operation on this page that's exactly what a beginner would guess.
Accuracy and Limitations
The calculator computes in IEEE double-precision floating point, the same as Python, JavaScript and Excel. That has two consequences you should know about.
Results that should be exact may show as long decimals
0.1 + 0.2 in floating point is 0.30000000000000004. So an inverse whose true entry is 1/3 will display as 0.333333…, and a determinant that should be exactly 0 may come out as 2.2 × 10⁻¹⁶. If you see a determinant smaller than about 10⁻¹⁰ on a matrix of ordinary-sized entries, treat it as zero: the matrix is singular and the "inverse" the calculator shows is noise.
Ill-conditioned matrices lose precision
A matrix whose rows are almost parallel (a Hilbert matrix, or any two rows that differ by a rounding error) can have a nonzero determinant and still produce an inverse that's wrong in the third significant figure. The calculator will not warn you. If the entries of your inverse are enormous (10⁶ and up) when the inputs were small, the matrix is nearly singular and the result is untrustworthy.
What this tool doesn't do yet: eigenvalues and eigenvectors, RREF as a separate output, complex entries, and symbolic (variable) entries. For those, a computer algebra system is the right tool. For everything in the table at the top, a matrix calculator online is faster than either a CAS or a graphing calculator, and this one shows the working.
Frequently Asked Questions (FAQs)
How do you multiply two matrices?
Multiply each row of the first matrix by each column of the second and add the products. Entry (i, j) of the result is row i of A dotted with column j of B. It only works when the columns of A equal the rows of B.
What dimensions are needed for matrix multiplication?
An m×n matrix times an n×p matrix. The inner numbers (n) must match; the result is m×p.
Can you add matrices of different sizes?
No. Addition and subtraction are element by element, so both matrices need identical dimensions. That's true in any matrices calculator, not a limitation of this one.
How do you find the determinant of a 3×3 matrix?
Cofactor expansion along any row or column, or the Rule of Sarrus. Both are worked in full above. For 4×4 and larger, only cofactor expansion (or elimination) works.
When does a matrix have an inverse?
When it's square and its determinant is not zero. A determinant of zero means the matrix is singular and no inverse exists.
What's the difference between a matrix solver and a matrix calculator?
Nothing, in practice. "Matrix solver" usually means someone wants to solve a system of equations, which is the row echelon operation here. A matrices calculator, a matrix solver and an online matrix calculator are all the same thing with a different name typed into Google.
Why does my inverse have decimals when the textbook has fractions?
Floating point. 1/3 and 0.3333333333 are the same number; the calculator displays the decimal. Convert with the fraction calculator if you need the printed form.
Why use a matrix calculator online instead of a graphing calculator?
Mostly screen size and copy-paste. A TI-84 will invert a 3×3 but you'll be scrolling to read it. Here you can see a 6×6 result at once, and paste the input from a spreadsheet. If you need more than matrices, the scientific calculator covers the rest.