# How do I find an inverse matrix?

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.

- Page: https://www.acalculator.org/math/inverse-matrix-calculator
- JSON spec: https://www.acalculator.org/math/inverse-matrix-calculator.json
- Version: 656dd6f1d272

## Default answer

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.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| a | Matrix A | The square matrix to invert, 1 to 6 rows and the same number of columns. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| inverse | Inverse A⁻¹ | The inverse matrix as exact fractions, rows separated by semicolons. |
| decimal | A⁻¹ in decimals | The same matrix in decimals, each number rounded to 10 significant figures. |
| determinant | Determinant | det(A) as an exact fraction. A matrix has an inverse exactly when it is not 0. |
| steps | Row operations on [A \| I] | The row operations that turn [A \| I] into [I \| A⁻¹], in order (the first 30). |

## 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.

## Assumptions

- 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

1. a = 1 or 2 or 2 or 5 gives inverse = [-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.
2. a = 4 or 7 or 2 or 6 gives inverse = [3/5, -7/10; -1/5, 2/5], decimal = [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].
3. a = 0 or 1 or 1 or 0 gives inverse = [0, 1; 1, 0], determinant = -1, steps = R1 ↔ R2. Source: hand calculation in content.mdx: swapping two rows twice gives I, so the swap is its own inverse.
4. a = 4 or undefined or undefined gives inverse = [1/4], decimal = [0.25], determinant = 4. Source: hand calculation in content.mdx: the inverse of a 1 × 1 matrix [a] is [1/a].
5. a = 0.5 or 0 or 0.1 or 0.25 gives inverse = [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).

## FAQ

### 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.

## Sources

- NIST Digital Library of Mathematical Functions, §1.2(vi) Square Matrices, equation 1.2.60 (the inverse: AA⁻¹ = A⁻¹A = I; if det(A) ≠ 0, A has a unique inverse). https://dlmf.nist.gov/1.2
- Gilbert Strang, Introduction to Linear Algebra, 5th ed., §2.5 Inverse Matrices (Gauss-Jordan eliminates [A I] to [I A⁻¹]; the 2 by 2 inverse and ad − bc). https://math.mit.edu/~gs/linearalgebra/ila5/linearalgebra5_2-5.pdf
