How do I find an inverse matrix?
Type a square matrix to get its inverse as exact fractions, with the determinant and the row operations that produce it.
- Inverse A⁻¹
- [-40, 16, 9; 13, -5, -3; 5, -2, -1]
The inverse of the matrix is [-40, 16, 9; 13, -5, -3; 5, -2, -1], and its determinant is -1.
- A⁻¹ in decimals
- [-40, 16, 9; 13, -5, -3; 5, -2, -1]
- Determinant
- -1
- Row operations on [A | I]
- R2 → R2 − 2 × R1; R3 → R3 − R1; R1 → R1 − 2 × R2; R3 → R3 + 2 × R2; R3 → -1 × R3; R1 → R1 − 9 × R3; R2 → R2 + 3 × R3
Inverse A⁻¹: [-40, 16, 9; 13, -5, -3; 5, -2, -1]. The inverse of the matrix is [-40, 16, 9; 13, -5, -3; 5, -2, -1], and its determinant is -1.
Row operations on [A | I]
How to calculate
Finds the inverse A⁻¹ of a square matrix (1 × 1 to 6 × 6) by Gauss-Jordan elimination in exact fractions, with the determinant and every row operation.
Example with the default inputs (Matrix A [1, 2, 3; 2, 5, 3; 1, 0, 8]): The inverse of the matrix is [-40, 16, 9; 13, -5, -3; 5, -2, -1], and its determinant is -1.
Method: Gauss-Jordan elimination: row-reduce the n × 2n matrix [A | I]. When the left half becomes I, the right half is A⁻¹. The determinant is the product of the pivots, times −1 for each row swap.
- Every entry is read as an exact fraction: a decimal such as 0.1 is 1/10, so there is no rounding in the elimination.
- A matrix has an inverse exactly when its determinant is not 0. A singular matrix has no inverse, and the calculator says so.
- The pivot in each column is the first row, from the top of the rows not yet used, with a non-zero entry.
- The matrix is square, 1 × 1 to 6 × 6.
Worked examples
Each example is checked against the calculator on every build.
- Matrix A 1, 2, 3; 2, 5, 3; 1, 0, 8 gives Inverse A⁻¹ [-40, 16, 9; 13, -5, -3; 5, -2, -1], Determinant -1.Source: hand calculation in content.mdx (Gauss-Jordan on [A | I], Strang section 2.5); Python fractions check
- Matrix A 4, 7; 2, 6 gives Inverse A⁻¹ [3/5, -7/10; -1/5, 2/5], A⁻¹ in decimals [0.6, -0.7; -0.2, 0.4], Determinant 10.Source: hand calculation in content.mdx: the 2 × 2 formula, 1/(4 × 6 − 7 × 2) × [6, −7; −2, 4]
- Matrix A 0, 1; 1, 0 gives Inverse A⁻¹ [0, 1; 1, 0], Determinant -1, Row operations on [A | I] R1 ↔ R2.Source: hand calculation in content.mdx: swapping two rows twice gives I, so the swap is its own inverse
- Matrix A 4 gives Inverse A⁻¹ [1/4], A⁻¹ in decimals [0.25], Determinant 4.Source: hand calculation in content.mdx: the inverse of a 1 × 1 matrix [a] is [1/a]
- Matrix A 0.5, 0; 0.1, 0.25 gives Inverse A⁻¹ [2, 0; -4/5, 4], Determinant 1/8.Source: hand calculation in content.mdx: lower triangular, det = 0.5 × 0.25 = 1/8; decimals read exactly (0.1 is 1/10)
How it works
The inverse of a square matrix A is the matrix A⁻¹ with A × A⁻¹ = A⁻¹ × A = I, the identity matrix. The calculator finds it by Gauss-Jordan elimination:
- Write the n × 2n matrix [A | I]: A with the identity matrix to its right.
- For each column from the left: take the first row (from the top of the rows not yet used) with a non-zero entry in that column as the pivot row, and swap it up if needed.
- Divide the pivot row by its pivot, so the pivot is 1.
- Subtract multiples of the pivot row from every other row, so the rest of the column is 0.
- When the left half is I, the right half is A⁻¹. If a column of the left half has no non-zero entry to pivot on, the determinant is 0 and A has no inverse.
The determinant comes from the same steps. Each swap multiplies it by −1, each scaling by 1 ÷ pivot multiplies it by 1 ÷ pivot, and adding a multiple of a row leaves it unchanged. The steps end at I, whose determinant is 1, so det(A) is the product of the pivots, times −1 for each swap.
Assumptions
- Every entry is read exactly as typed, as a fraction: 0.1 is 1/10. All the arithmetic is exact, so the inverse and the determinant have no rounding.
- The matrix is square, from 1 × 1 to 6 × 6.
- The decimal version rounds each exact entry to 10 significant figures, as JavaScript's
toPrecision(10)does: to the nearest, and an exact tie in the entry's double value rounds away from zero. It is then written as the shortest JavaScript number, so trailing zeros go, and an entry below 10⁻⁶ in size (or 10²¹ and above) is written in e notation, such as 5.77962679e-9 or 1e-9. - The working lists at most the first 30 row operations, separated by "; ", then "and N more" when there are more. Rows count from 1, and fractions are in lowest terms with a plain hyphen: a swap is "R1 ↔ R2", scaling is "R1 → 1/3 × R1" (or "R3 → -1 × R3"), and adding a multiple is "R3 → R3 − 2 × R1" or "R3 → R3 + 2/5 × R1" (the true minus sign between terms, and no "1 ×" for a multiple of 1: "R3 → R3 − R1"). A matrix already equal to I gives an empty working.
- Matrices are written row by row in square brackets, rows separated by "; " and entries by ", ": [3/5, -7/10; -1/5, 2/5]. Fractions are in lowest terms with a plain hyphen for negatives, and the determinant is written the same way (-1, 1/8).
Worked examples by hand
A = [1, 2, 3; 2, 5, 3; 1, 0, 8]. Start from [A | I].
- Column 1, pivot 1: R2 → R2 − 2 × R1 gives [0, 1, −3 | −2, 1, 0]; R3 → R3 − R1 gives [0, −2, 5 | −1, 0, 1].
- Column 2, pivot 1: R1 → R1 − 2 × R2 gives [1, 0, 9 | 5, −2, 0]; R3 → R3 + 2 × R2 gives [0, 0, −1 | −5, 2, 1].
- Column 3, pivot −1: R3 → −1 × R3 gives [0, 0, 1 | 5, −2, −1]; R1 → R1 − 9 × R3 gives [1, 0, 0 | −40, 16, 9]; R2 → R2 + 3 × R3 gives [0, 1, 0 | 13, −5, −3].
So A⁻¹ = [−40, 16, 9; 13, −5, −3; 5, −2, −1]. There were no swaps, and the pivots were 1, 1, and −1, so det(A) = −1.
A = [4, 7; 2, 6]. ad − bc = 4 × 6 − 7 × 2 = 10, so A⁻¹ = 1/10 × [6, −7; −2, 4] = [3/5, −7/10; −1/5, 2/5], or [0.6, −0.7; −0.2, 0.4].
A = [0, 1; 1, 0]. Column 1 has 0 at the top, so swap R1 and R2. That already gives I, so the matrix is its own inverse, and the one swap makes det(A) = −1.
A = [4]. The inverse of a 1 × 1 matrix [a] is [1/a], so A⁻¹ = [1/4] and det(A) = 4.
A = [0.5, 0; 0.1, 0.25]. Read exactly, this is [1/2, 0; 1/10, 1/4]. It is lower triangular, so det(A) = 1/2 × 1/4 = 1/8. The 2 × 2 formula gives A⁻¹ = 8 × [1/4, 0; −1/10, 1/2] = [2, 0; −4/5, 4].
Other questions people ask
How do I find the inverse of a matrix?
Write A next to the identity matrix, [A | I], and use row operations (swap rows, scale a row, add a multiple of one row to another) until the left half is I. The right half is then A⁻¹. If the left half cannot be made into I, A has no inverse.
What is the formula for the inverse of a 2 × 2 matrix?
For A = [a, b; c, d], A⁻¹ = 1/(ad − bc) × [d, −b; −c, a]: swap a and d, change the signs of b and c, and divide by the determinant ad − bc. For [4, 7; 2, 6], ad − bc = 10 and A⁻¹ = [0.6, −0.7; −0.2, 0.4].
When does a matrix have no inverse?
When its determinant is 0. Then one row is a combination of the others (as in [1, 2; 2, 4], where the second row is twice the first), elimination leaves a row of zeros, and no matrix times A gives I. Such a matrix is called singular.
How do I check an inverse?
Multiply: A × A⁻¹ must equal the identity matrix I, with 1s on the diagonal and 0s elsewhere. The calculator checks this exactly for every answer.
Why are the answers fractions?
Inverses of whole-number matrices are usually fractions, because the elimination divides by the pivots. Exact fractions have no rounding error; the decimal version is shown too, rounded to 10 significant figures.
What is the inverse used for?
To solve a system of linear equations Ax = b, x = A⁻¹b. It also undoes a transformation: if A turns a vector into another, A⁻¹ turns it back. For one system, row-reducing [A | b] is less work than finding A⁻¹.
Can a non-square matrix have an inverse?
No. Only a square matrix can have a two-sided inverse with A⁻¹A = AA⁻¹ = I. That is why the grid stays square.