Matrix Calculator
Add, multiply, transpose, find determinant, inverse and rank up to 5×5, in fractions
| 25 | 36 |
| 20 | 28 |
Runs entirely in your browser. Nothing you type or upload is sent to us or stored.
Results are for general guidance. Please check anything important before relying on it. Terms of use
How to Use
- Set the size of matrix A and matrix B with the row and column pickers (anything from 1×1 to 5×5), then type the entries. Whole numbers, fractions such as 2/3 and decimals all work; an empty cell counts as 0.
- Choose an operation: A + B, A − B, A × B, k × M, transpose, determinant, inverse, rank or trace. For the single-matrix operations, pick on A or on B.
- The result appears straight away, in exact fractions when your entries are whole numbers or fractions. Switch between Fractions and Decimals if you prefer. The determinant also shows its working.
- Use copy as text or copy as CSV to paste the answer elsewhere. swap A and B exchanges the two matrices, and the example buttons fill in sample matrices.
Matrix calculator with exact fractions
This matrix calculator adds, subtracts and multiplies matrices up to 5×5, and finds the transpose, determinant, inverse, rank and trace. It works with exact fractions, so the inverse of a matrix with whole-number entries comes out as 3/5 and −7/10 rather than 0.6 and −0.7 (switch to decimals if you want those). That makes it easy to check Class 12 matrix and determinant exercises, where answers are normally written as fractions or as (1/|A|) × adj A.
When each operation is possible
| Operation | Size rule | Result size |
|---|---|---|
| A + B, A − B | A and B the same size | Same as A |
| A × B | Columns of A = rows of B | Rows of A × columns of B |
| k × A, transpose | Any size | Same, or flipped for the transpose |
| Determinant, inverse, trace | Square only | A number (inverse: same as A) |
| Rank | Any size | A whole number |
Matrix multiplication is not commutative: A × B and B × A are usually different, and one of them may not even exist. With A = [1 2; 3 4] and B = [5 6; 7 8], A × B = [19 22; 43 50] but B × A = [23 34; 31 46]. Use swap A and B to see both.
Determinant
For a 2×2 matrix the determinant is ad − bc. For a 3×3 matrix the calculator expands along the first row, the method taught in NCERT Class 12:
|A| = 2(3×4 − 2×1) − (−1)(1×4 − 2×0) + 0(1×1 − 3×0)
= 2 × 10 + 1 × 4 + 0 = 24
For 4×4 and 5×5 matrices it uses row reduction: turn the matrix into upper triangular form, then multiply the diagonal entries, changing the sign once for every row swap. Both methods give the same answer.
Inverse
A square matrix has an inverse only when its determinant is not 0. For a 2×2 matrix:
[4 7; 2 6]⁻¹ = (1/10) × [6 −7; −2 4] = [3/5 −7/10; −1/5 2/5]
For larger matrices the textbook formula is A⁻¹ = adj(A)/|A|. The calculator gets the same result by Gauss-Jordan elimination: it row-reduces [A | I] until the left half becomes the identity, and the right half is then A⁻¹. You can check any inverse by multiplying: A × A⁻¹ should give the identity matrix I. If the determinant is 0, the matrix is singular and the calculator says so. [1 2 3; 4 5 6; 7 8 9] is the classic example.
Rank and trace
The rank is the number of rows that are linearly independent: after row reduction, it is the number of non-zero rows. [1 2 3; 4 5 6; 7 8 9] has rank 2, because the third row equals 2 × (second row) − (first row). Comparing ranks tells you whether a system of linear equations has one solution, none or infinitely many. Consistency of such systems is part of the JEE Main syllabus. The trace is the sum of the main diagonal: for [1 2; 3 4] it is 1 + 4 = 5.
Tips
- Type fractions directly (1/3) rather than 0.333. A decimal entry switches the display to decimals, but the arithmetic stays exact either way.
- Copy as CSV pastes cleanly into Excel or Google Sheets, one row per line.
- To solve AX = B, find A⁻¹ here and multiply it by B, or use the System tab of the equation solver.