What each matrix operation needs
A matrix with m rows and n columns is an m×n matrix. Some operations work on any matrix, others need a square one or two matrices of matching sizes. The calculator checks this first and tells you which size is off.
| Operation | Needs | Result |
|---|---|---|
| A + B, A − B | A and B the same size | Same size, entry by entry |
| A × B | Columns of A = rows of B | Rows of A × columns of B |
| k × A | Any matrix and a number k | Same size, every entry times k |
| Transpose Aᵀ | Any matrix | n×m: rows become columns |
| Determinant | Square matrix | One number |
| Inverse A⁻¹ | Square matrix with det A ≠ 0 | Same size, A × A⁻¹ = I |
| Rank, RREF | Any matrix | A number; a matrix of the same size |
| Power Aⁿ | Square matrix | Same size |
How matrix multiplication works
Each entry of the product is a row of A times a column of B. Multiply the matching entries and add them up:
For A = [1 2 3; 4 5 6] and B = [7 8; 9 10; 11 12], the top-left entry is 1·7 + 2·9 + 3·11 = 58, and the whole product is [58 64; 139 154]. B × A also exists here, but it is a 3×3 matrix, so the order of the factors matters. Use the fraction calculator if you want to check a single entry with fractions by hand.
Determinant: two ways, one answer
The determinant is one number that tells you whether a square matrix can be inverted: it can exactly when the determinant is not 0. For a 2×2 matrix [a b; c d] it is ad − bc. For larger matrices there are two methods, and the calculator shows both.
- Row reduction. Subtracting a multiple of one row from another does not change the determinant, and swapping two rows flips its sign. Eliminate until the matrix is upper triangular, then multiply the diagonal. This is also how computers find the determinant of a large matrix.
- Cofactor expansion. Pick a row or column, multiply each entry by its cofactor (−1)i+j × Mᵢⱼ, where the minor Mᵢⱼ is the determinant left after deleting that entry’s row and column, and add the results. A row with zeros saves work, so the calculator picks the line with the most zeros.
Worked example
Take A = [2 −3 1; 2 0 −1; 1 4 5]. Row 2 has a zero, so expand along it. The entry 2 sits in position (2, 1) with sign −, and its minor is (−3)·5 − 1·4 = −19, so the term is −2 × (−19) = 38. The entry −1 sits in position (2, 3) with sign −, and its minor is 2·4 − (−3)·1 = 11, so the term is −(−1) × 11 = 11. The determinant is 38 + 11 = 49.
By row reduction: subtract row 1 from row 2 and half of row 1 from row 3, then 11/6 of the new row 2 from row 3. The diagonal is 2, 3 and 49/6, and 2 × 3 × 49/6 = 49 again.
Inverse with Gauss-Jordan elimination
Put A and the identity matrix side by side as [A | I]. Eliminate downward until A is upper triangular, then work upward: divide each pivot row by its pivot and clear the entries above it. When the left half has become I, the right half is A⁻¹.
For A = [2 −1 0; −1 2 −1; 0 −1 2] the pivots are 2, 3/2 and 4/3, so det A = 2 × 3/2 × 4/3 = 4 and the inverse exists. After the upward pass the right half is
If a column runs out of pivots on the way, the matrix is singular and has no inverse. Try the example [1 2 3; 4 5 6; 7 8 9]: its third row is twice the second minus the first, and the steps show the column where elimination stops.
Rank and reduced row echelon form
Elimination also works on matrices that are not square. The number of pivots it finds is the rank. For [1 2 2 2; 2 4 6 8; 3 6 8 10] the third row is a combination of the first two, so only two pivots appear and the rank is 2. Going on to the reduced row echelon form gives [1 2 0 −2; 0 0 1 2; 0 0 0 0]: a 1 in each pivot, zeros above and below it. Columns without a pivot are the free columns. That is exactly what the system of equations solver uses to describe infinitely many solutions.
Exact fractions, no rounding
Most online calculators work with decimals and round in every step, so an inverse can come out as 0.33333 where the truth is 1/3, and a determinant can show 0.0000001 where the true value is 0. This calculator stores every entry as a fraction of two whole numbers of any length. Additions, products and divisions are exact, so a singular matrix is always recognized as singular and the steps show the same fractions you would get by hand. Decimals are only produced for display, rounded to four places when you choose them. For single numbers with trig or logs, use the scientific calculator.
How to use the matrix calculator
- 1Choose the operation. For A + B, A − B and A × B a second matrix appears.
- 2Set the size of each matrix with the rows and columns menus, then type the entries. Empty cells count as 0, and you can paste a block of cells from a spreadsheet.
- 3Read the result and follow the steps below it. Switch between Fractions and Decimals, and for a determinant between Row reduction and Cofactor expansion.
- 4Press Use result as A to keep calculating with the answer, Copy result to copy it with the steps, or Copy link to share the matrices.
Sources
- Multiplication and inverse matrices, MIT OpenCourseWare 18.06SC Linear Algebra, lecture summary: row times column, Gauss-Jordan elimination on [A | I]
- Properties of determinants, MIT OpenCourseWare 18.06SC: row swaps, row subtraction, triangular matrices, det A = 0 for singular matrices
- Cramer’s rule, inverse matrix and volume, MIT OpenCourseWare 18.06SC: A⁻¹ = Cᵀ ÷ det A
- Solving Ax = 0: pivot variables, special solutions, MIT OpenCourseWare 18.06SC: rank as the number of pivots, reduced row echelon form
Frequently asked questions
How do you find the inverse of a matrix?
Write the matrix and the identity matrix side by side as [A | I] and use row operations until the left half is the identity. The right half is then the inverse. This is Gauss-Jordan elimination, and the calculator shows each row operation. For a 2×2 matrix there is a shortcut: swap a and d, change the signs of b and c, and divide everything by ad − bc.
Why does my matrix have no inverse?
A square matrix has an inverse exactly when its determinant is not 0. If the determinant is 0, the matrix is singular: at least one row is a combination of the others, so elimination runs out of pivots before the left half becomes the identity. The steps show the column where that happens. A matrix that is not square never has an inverse.
Why can’t I multiply these two matrices?
A × B only works when A has as many columns as B has rows. A 2×3 matrix times a 3×4 matrix gives a 2×4 matrix, but a 2×3 matrix cannot be multiplied by a 2×3 matrix. Order matters too: A × B and B × A are usually different, and one of them may not exist at all.
Should I use row reduction or cofactor expansion for the determinant?
Both give the same number. Cofactor expansion is easy to follow for 2×2 and 3×3 matrices, especially along a row with zeros. Row reduction is much faster for larger matrices: make the matrix upper triangular and multiply the diagonal, flipping the sign once for every row swap. Switch between the two methods to compare.
What do rank and reduced row echelon form tell you?
The rank is the number of pivots after elimination: how many rows (or columns) are truly independent. The reduced row echelon form has a 1 in every pivot position and zeros above and below it. It is unique for every matrix, so it is the standard way to read off the solutions of a linear system.
Can I enter fractions and decimals?
Yes. Type whole numbers, decimals like 0.75 or fractions like 3/4 and −1/2, and leave a cell empty for 0. The calculator works with exact fractions throughout, so 1/3 stays 1/3. Switch the display to decimals to see every entry rounded to four places.
Can I paste a matrix from a spreadsheet?
Yes. Copy a block of cells and paste it into the top-left cell of the grid. Rows and columns are split at line breaks and tabs, and the grid grows to fit, up to 6 rows and 6 columns.