## Computing the inverse of a matrix over a field

Let $A$ be an $n \times n$ matrix over a field.

1. Suppose $B = [B_1 | \cdots | B_n]$ is a matrix with columns $B_i$, and let $e_i$ denote the $i$th standard basis vector. Prove that $B$ is an inverse of $A$ if and only if $B_i$ is a solution of the matrix equation $AX = e_i$ for each $i$.
2. Prove that $A$ has an inverse if and only if $A$ is row equivalent to the identity matrix.
3. Prove that $A$ has an inverse $B$ if and only if $[A|I]$ and $[I|B]$ are row equivalent.

We begin with a lemma.

Lemma: Let $A$ and $B$ be matrices of dimension $n \times n$ over a field. If $AB = I$, then $BA = I$. Proof: Thinking of $A$ and $B$ as linear transformations, since $AB$ is injective, $A$ is injective. Since we are working over a vector space of finite dimension, $A$ is also surjective. So $A$ is an automorphism. Thus there exists a matrix $C$ such that $CA = I$, and we have $C = CAB = B$. So $BA = I$. $\square$

Thus, in $\mathsf{Mat}_n(F)$, to show a matrix is invertible it suffices to show left- or right-invertible.

1. Suppose $B$ is an inverse of $A$. Then we have $AB = [AB_1 | \cdots | AB_n] = [e_1 | \cdots | e_n]$. In particular, $B_i$ is a solution of the equation $AX = e_i$ for each $i$. Conversely, if $AB_i = e_i$ for each $i$, then $AB = [AB_1 | \cdots | AB_n]$ $= [e_1 | \cdots | e_n] = I$. Thus $B$ is an inverse of $A$.
2. Suppose there is a matrix $B$ such that $BA = I$. In particular, $B$ is invertible, and so $A$ is row equivalent to the identity matrix. Conversely, if $A$ is row equivalent to the identity matrix, then $BA = I$ for some invertible matrix $B$. By the lemma, $B$ is an inverse of $A$.
3. Suppose $A$ is invertible with inverse $B$. Then $B[A|I] = [BA|B] = [I|B]$, so that $[A|I]$ and $[I|B]$ are row equivalent. Now suppose $[A|I]$ and $[I|B]$ are row equivalent, say by an invertible matrix $P$. Then $P[A|I] = [PA|P] = [I|B]$. Thus $P = B$ and $BA = I$, so that $B$ is an inverse of $A$.