Matrix Calculator
To find the inverse of a matrix, row-reduce A next to the identity matrix until the left half becomes I: for A = [[2, 1], [1, 2]], A⁻¹ = [[2/3, −1/3], [−1/3, 2/3]]. For a 2 × 2 matrix the determinant is ad − bc, so det [[2, 1], [1, 2]] = 3; larger ones are reduced by row operations. Add or subtract matrices of the same size entry by entry: [[1, 2], [3, 4]] + [[5, 6], [7, 8]] = [[6, 8], [10, 12]]. Multiply by taking each row of A times each column of B: [[1, 2], [3, 4]] × [[5, 6], [7, 8]] = [[19, 22], [43, 50]]. The rank is the number of pivots in the row-reduced form: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] has rank 2. This calculator takes matrices up to 6 × 6 as integers, decimals or fractions, keeps every result exact, and lists the row operations.
Updated Runs in your browser: nothing you enter is uploadedHow this tool works
A⁻¹ = [[2/3, −1/3], [−1/3, 2/3]]
| Column 1 | Column 2 | |
|---|---|---|
| Row 1 | 2/3 | −1/3 |
| Row 2 | −1/3 | 2/3 |
- Size
- 2 × 2
- Determinant of A
- 3
- Check
- A × A⁻¹ = I
The working, step by step
- Write A next to the 2 × 2 identity matrix I, then row-reduce [A | I] until the left half is I. The right half is then A⁻¹.
- Start with the matrix.
Column 1 Column 2 Column 3 Column 4 Row 1 2 1 1 0 Row 2 1 2 0 1 - R1 ← R1 ÷ 2 (make the pivot in column 1 equal to 1).
Column 1 Column 2 Column 3 Column 4 Row 1 1 1/2 1/2 0 Row 2 1 2 0 1 - R2 ← R2 − R1 (clear the rest of column 1).
Column 1 Column 2 Column 3 Column 4 Row 1 1 1/2 1/2 0 Row 2 0 3/2 −1/2 1 - R2 ← R2 ÷ (3/2) (make the pivot in column 2 equal to 1).
Column 1 Column 2 Column 3 Column 4 Row 1 1 1/2 1/2 0 Row 2 0 1 −1/3 2/3 - R1 ← R1 − (1/2)·R2 (clear the rest of column 2).
Column 1 Column 2 Column 3 Column 4 Row 1 1 0 2/3 −1/3 Row 2 0 1 −1/3 2/3 - The left half is now I, so the right half is the inverse A⁻¹.
Worked examples
| Operation | Matrices | Result |
|---|---|---|
| Add: A + B | A = [[1, 2], [3, 4]], B = [[5, 6], [7, 8]] | [[6, 8], [10, 12]] |
| Multiply: A × B | A = [[1, 2], [3, 4]], B = [[5, 6], [7, 8]] | [[19, 22], [43, 50]] |
| Multiply (reversed): B × A | B = [[5, 6], [7, 8]], A = [[1, 2], [3, 4]] | [[23, 34], [31, 46]] |
| Scalar multiply: 1/2 × A | A = [[2, 4], [6, 8]] | [[1, 2], [3, 4]] |
| Transpose: Aᵀ | A = [[1, 2, 3], [4, 5, 6]] | [[1, 4], [2, 5], [3, 6]] |
| Determinant: det(A) | A = [[6, 1, 1], [4, −2, 5], [2, 8, 7]] | [[−306]] |
| Inverse: A⁻¹ | A = [[2, 1], [1, 2]] | [[2/3, −1/3], [−1/3, 2/3]] |
| Inverse (decimals): A⁻¹ | A = [[0.5, 0.25], [1.5, 2]] | [[16/5, −2/5], [−12/5, 4/5]] |
| Rank: rank(A) | A = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] | [[2]] |
| RREF: rref(A) | A = [[1, 2, 3], [4, 5, 6]] | [[1, 0, −1], [0, 1, 2]] |
Determinant, rank and invertibility of special matrices
| Matrix | Entries | Determinant | Rank | Invertible |
|---|---|---|---|---|
| Identity matrix | [[1, 0, 0], [0, 1, 0], [0, 0, 1]] | 1 | 3 | Yes |
| Diagonal matrix | [[2, 0, 0], [0, 3, 0], [0, 0, 4]] | 24 | 3 | Yes |
| Upper triangular matrix | [[1, 2, 3], [0, 4, 5], [0, 0, 6]] | 24 | 3 | Yes |
| Rows that are multiples | [[1, 2], [2, 4]] | 0 | 1 | No |
| Rows in arithmetic progression | [[1, 2, 3], [4, 5, 6], [7, 8, 9]] | 0 | 2 | No |
| Swap matrix | [[0, 1], [1, 0]] | −1 | 2 | Yes |
| Hilbert matrix (fractions) | [[1, 1/2, 1/3], [1/2, 1/3, 1/4], [1/3, 1/4, 1/5]] | 1/2160 | 3 | Yes |
Which sizes each operation accepts
| Operation | Needs | Example |
|---|---|---|
| Add or subtract | A and B the same size | 2 × 2 and 2 × 2 give 2 × 2 |
| Multiply A × B | columns of A = rows of B | 2 × 3 times 3 × 4 gives 2 × 4 |
| Scalar multiply | any size | 2 × 2 gives 2 × 2 |
| Transpose | any size | 2 × 3 gives 3 × 2 |
| Determinant, inverse | square only (n × n) | 3 × 3 gives 3 × 3 for the inverse |
| Rank, RREF | any size | 2 × 3 gives 2 × 3 for the RREF |
How to find the inverse of a matrix by hand
- Check the matrix is square. Only an n × n matrix can have an inverse. For a 2 × 2 matrix, find det = ad − bc: here 3. If the determinant is 0 there is no inverse.
- Write A next to the identity matrix. Build the augmented matrix [A | I]. For [[2, 1], [1, 2]] the right half is [[1, 0], [0, 1]].
- Row-reduce the left half to the identity. Use three row operations: swap two rows, multiply a row by a non-zero number, or add a multiple of one row to another. Work column by column: make the pivot 1, then clear the rest of its column.
- Read the inverse from the right half. When the left half is I, the right half is A⁻¹: [[2/3, −1/3], [−1/3, 2/3]].
- Check by multiplying. A × A⁻¹ must give the identity matrix. The calculator confirms it for you: A × A⁻¹ = I.
Frequently asked questions
- How do you find the determinant of a matrix?
- For a 2 × 2 matrix [[a, b], [c, d]] the determinant is ad − bc: for [[2, 1], [1, 2]] it is 2·2 − 1·1 = 3. For larger matrices, reduce to an upper triangular matrix with row operations that add a multiple of one row to another, which leave the determinant unchanged, and multiply the diagonal. Each row swap flips the sign. For [[6, 1, 1], [4, −2, 5], [2, 8, 7]] the result is −306.
- When does a matrix have no inverse?
- When it is not square, or when its determinant is 0 (it is “singular”). That happens when one row is a combination of the others, for example [[1, 2], [2, 4]], whose second row is twice the first. Row reduction then runs out of pivots before the left half becomes the identity, and the calculator says so instead of giving an answer.
- How do you multiply two matrices?
- Each entry of A × B is a row of A times a column of B: multiply matching entries and add. [[1, 2], [3, 4]] × [[5, 6], [7, 8]] = [[19, 22], [43, 50]], because the top-left entry is 1·5 + 2·7 = 19. A must have as many columns as B has rows, and the result has A’s rows and B’s columns: a 2 × 3 matrix times a 3 × 4 matrix is 2 × 4.
- Is matrix multiplication commutative?
- No. A × B and B × A are usually different, and one of them may not even exist. With the same two matrices, A × B = [[19, 22], [43, 50]] but B × A = [[23, 34], [31, 46]]. Matrix multiplication is associative, though, so (AB)C = A(BC).
- What is the rank of a matrix?
- The rank is the number of pivots in its reduced row echelon form, which equals the number of linearly independent rows (and of independent columns). The 3 × 3 matrix [[1, 2, 3], [4, 5, 6], [7, 8, 9]] looks full but has rank 2, because its third row is twice the second minus the first. A square matrix is invertible exactly when its rank equals its size.
- What is RREF (reduced row echelon form)?
- A matrix where each non-zero row starts with a 1 (the pivot), each pivot is to the right of the one above it, and every pivot is the only non-zero entry in its column. [[1, 2, 3], [4, 5, 6]] reduces to [[1, 0, −1], [0, 1, 2]]. Solving a system of linear equations reduces to reading its augmented matrix in RREF, and the calculator lists each row operation that gets there.
- Can I enter decimals and fractions?
- Yes: integers (3), decimals (0.75) and fractions (3/4) all work in the same matrix, and every result is exact. The inverse of [[0.5, 0.25], [1.5, 2]] is [[16/5, −2/5], [−12/5, 4/5]], not a rounded decimal, and the inverse of the Hilbert matrix [[1, 1/2, 1/3], [1/2, 1/3, 1/4], [1/3, 1/4, 1/5]] comes out as whole numbers: [[9, −36, 30], [−36, 192, −180], [30, −180, 180]].
- How do I paste a matrix?
- Open “Paste matrix” under the grid, put one row per line with the numbers separated by spaces, tabs or commas, and press the fill button. A selection copied from a spreadsheet works as it is, and so do forms like [[1,2],[3,4]] or 1 2; 3 4. Write fractions without spaces, as 3/4. The grid takes the size of what you pasted, up to 6 × 6.
- What does the transpose do?
- It turns rows into columns: entry (i, j) moves to (j, i). The 2 × 3 matrix [[1, 2, 3], [4, 5, 6]] becomes the 3 × 2 matrix [[1, 4], [2, 5], [3, 6]]. The determinant of a square matrix is the same as its transpose’s.
- What changes the sign of a determinant?
- Swapping two rows flips it: the swap matrix [[0, 1], [1, 0]] has determinant −1. Adding a multiple of one row to another changes nothing, and multiplying a row by a number multiplies the determinant by that number. The calculator counts the swaps it makes and applies the sign at the end.
How it works
Every entry you type is read as an exact fraction of two whole numbers (up to 12 digits each): a decimal is its digits over a power of 10, and a fraction a/b is kept as typed, then reduced to lowest terms. Addition, subtraction, scalar multiplication and matrix multiplication use the textbook definitions on those fractions, so nothing is ever rounded. The determinant, rank, RREF and inverse all come from one routine: Gaussian elimination on exact fractions, choosing the first non-zero entry at or below the diagonal as the pivot. The determinant stops at an upper triangular matrix using only “add a multiple of a row” operations, multiplies the diagonal and flips the sign once per row swap; for a 2 × 2 matrix it uses ad − bc directly. The rank counts pivots in the RREF. The inverse row-reduces [A | I] with Gauss-Jordan elimination and then checks that A × A⁻¹ is the identity. Each row operation is shown as it is made, with the matrix after it. Everything runs in your browser and nothing you type is sent anywhere.
Sources
More free tools
- Fraction CalculatorAdd, subtract, multiply and divide fractions and mixed numbers like 2 3/8 + 1 5/16, simplify, and convert to decimals, with every step shown.
- Quadratic Equation SolverSolve ax² + bx + c = 0 step by step: discriminant, exact and decimal roots (real or complex), vertex, factored form, completing the square and a graph.
- Scientific CalculatorFree online scientific calculator with live results: trig in DEG, RAD or GRAD, logs, powers, factorial, nPr, nCr, memory and history.
- Complex Number CalculatorAdd, subtract, multiply and divide complex numbers exactly, then find the modulus, argument, polar form, powers, square roots and roots of unity.
- System of Equations CalculatorSolve 2 or 3 linear equations exactly: row-reduction steps, determinant, Cramer’s rule and a graph. Finds one, no or infinitely many solutions.
- Arithmetic and Geometric Sequence CalculatorFind the nth term, the sum of the first n terms, the formulas and the infinite sum of an arithmetic, geometric or Fibonacci-like sequence, step by step.
More: Algebra and number theoryAll math & numbersAll toolsHome & DIY calculators