Computing a 2×2 Inverse

For a 2\times 2 matrix there is a tidy recipe for the inverse. Swap the two diagonal entries, negate the other two, and divide everything by the determinant:

A = \begin{bmatrix} a & b \\ c & d \end{bmatrix} \;\Rightarrow\; A^{-1} = \frac{1}{ad - bc}\begin{bmatrix} d & -b \\ -c & a \end{bmatrix}.

"Swap a and d, flip the sign of b and c, divide by the determinant." If the determinant is zero you'd be dividing by zero — which is the formula's way of telling you the matrix has no inverse.

Build the inverse live

Set the entries of A and the inverse is computed for you by the recipe above, alongside the determinant. Push the entries until the determinant hits zero and the formula breaks — exactly as it should, because no inverse exists there.

A quick sanity check

You can always verify an inverse by multiplying: A^{-1}A should come out to the identity \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}. Bigger matrices use Gaussian elimination instead of a one-line formula, but the 2×2 recipe is worth memorizing — it appears constantly, from solving little systems to the closed-form fit of linear regression.