Matrix Inverse
What must be true before an inverse exists
Two conditions hide inside the definition, and both have to be checked in an exam answer. The first is existence: multiplying and taking determinants gives , and a product of two real numbers can equal one only when neither factor is zero, so is forced. The converse is constructive rather than theoretical, because the candidate built from the adjoint really does satisfy the identity, as the next section shows. The second condition is uniqueness: if and were both inverses of , then , so there is never a choice to make between two different inverses.
Rectangular matrices are excluded from the discussion entirely. They can have a left inverse or a right inverse when the rank is full, but never both, and the definition used throughout this lesson demands both products at once.
From cofactors to the inverse formula
The route from entries to inverse has four stops, and each one is a single mechanical move: build the minors, attach the signs to get cofactors, assemble the cofactor matrix, transpose it to get the adjoint, and finally scale every entry by the reciprocal of the determinant.
| Quantity | Formula | What it means |
|---|---|---|
| Cofactor | a minor with a position sign attached | |
| Adjoint | the cofactor matrix written on its side | |
| Inverse | the adjoint scaled by the reciprocal determinant | |
| Check | both orders must return the identity |
That single identity carries the whole method. The entry in row and column of the product is a row of multiplied by a row of cofactors, so when it is the cofactor expansion along that row and equals , while when it is an expansion with the wrong row substituted in, giving a matrix with two identical rows and therefore the value zero. Dividing both sides by produces the formula immediately, and dividing is legitimate precisely because existence already told us the determinant is not zero.
Example 1: 2×2 matrix by the adjoint method
Example 2: 3×3 matrix by the adjoint method
Example 3: the inverse used to solve a system
The multiplication of a matrix by a column vector is what makes this a solution method rather than a curiosity: each unknown is one dot product between a row of the inverse and the constant vector. For a two-equation system that is two multiplications and two additions, which is cheaper than elimination once the inverse has already been computed, and the same inverse answers every right-hand side built on the same coefficient matrix.
Why the product rule reverses the order
Transformations are undone in the reverse of the order they were applied. If a row is first doubled and then a multiple of another row is added to it, the addition has to be removed first and the doubling divided out second, and that observation is the entire content of the rule. Matrix multiplication records the order of operations, so the inverse of a product must peel the last factor off first.
What happens when the determinant is zero
A singular matrix has no inverse, and the reason is visible in the identity rather than in any failed calculation. If then forces every column of the adjoint into the null space of , so the adjoint cannot be scaled into an inverse no matter what you divide by. The adjoint itself is often not zero: for the determinant is while the adjoint is , and the product is the zero matrix exactly as the identity demands.
Practically this means the workflow stops at step three. A student who reaches for a singular matrix has done nothing wrong; the error would be dividing by zero afterwards, or reporting an inverse that the identity immediately contradicts. Numerically the same situation raises an explicit error instead of returning a misleading number, and the block below shows both the non-zero adjoint of a singular matrix and the exception the library raises.
import numpy as np
def adjugate(a):
n = a.shape[0]
cof = np.array([[((-1) ** (i + j)) * np.linalg.det(
np.delete(np.delete(a, i, axis=0), j, axis=1))
for j in range(n)] for i in range(n)])
return cof.T
singular = np.array([[1., 2.], [2., 4.]])
regular = np.array([[1., 2.], [3., 4.]])
print("det(singular) :", round(float(np.linalg.det(singular)), 12)) # 0.0
print("adj(singular) :\n", adjugate(singular))
# [[ 4. -2.]
# [-2. 1.]]
print("A adj(A) == 0 :", np.allclose(singular @ adjugate(singular), 0)) # True
print("adj is non-zero :", not np.allclose(adjugate(singular), 0)) # True
try:
np.linalg.inv(singular)
except np.linalg.LinAlgError as err:
print("inv(singular) :", err) # Singular matrix
Verifying inverses in Python
The first check rebuilds the inverse from cofactors and compares it with the library result, the second multiplies the two out, and the third puts the reversal rule under the same spotlight as the worked proof.
import numpy as np
def inverse_by_adjoint(a):
det = np.linalg.det(a)
if abs(det) < 1e-12:
raise ValueError("determinant is zero, the inverse does not exist")
n = a.shape[0]
cof = np.array([[((-1) ** (i + j)) * np.linalg.det(
np.delete(np.delete(a, i, axis=0), j, axis=1))
for j in range(n)] for i in range(n)])
return cof.T / det
A = np.array([[1., 2.], [3., 4.]])
B = np.array([[2., 0., 1.], [1., 3., 2.], [1., 1., 1.]])
print("A inverse:\n", np.round(inverse_by_adjoint(A), 6))
# [[-2. 1.]
# [ 1.5 -0.5]]
print("A A^-1 is I :", np.allclose(A @ inverse_by_adjoint(A), np.eye(2)))
print("matches inv :", np.allclose(inverse_by_adjoint(A), np.linalg.inv(A)))
print("B A^-1 is I :", np.allclose(B @ inverse_by_adjoint(B), np.eye(3)))
P = np.array([[1., 2.], [0., 1.]])
Q = np.array([[3., 0.], [1., 2.]])
print("AB != BA :", not np.allclose(P @ Q, Q @ P))
print("(PQ)^-1 == Q^-1 P^-1 :",
np.allclose(np.linalg.inv(P @ Q),
np.linalg.inv(Q) @ np.linalg.inv(P)))
Every line returns True. The determinant check inside the helper is worth keeping in your own work as well: it converts a silent division by zero into a clear message, which is the numerical version of the existence condition stated at the top of this lesson.
Where marks are lost
The arithmetic in this topic is not what loses marks; the bookkeeping is. The four recurring failures are transposing the cofactor matrix or forgetting to, dividing by the determinant or forgetting to, quoting as the inverse of when one of the matrices is singular, and applying out of habit from the scalar world. A fifth failure is quieter: computing for a singular matrix and then insisting on an inverse, when the honest answer is that no inverse exists.
A quick self-check catches nearly all of them. Multiply the first row of your inverse by the first column of the original and confirm you get exactly , then take a different row and column and confirm you get ; if the identity does not come out, the fault is in the adjoint or the scaling, and it is cheaper to find it now than after the whole matrix has been written out.
Common Mistakes
Stopping at the cofactor matrix and labelling it as the inverse
Fix: Transpose to get the adjoint, then divide every entry by the determinant; the three steps are separate and the check A A-inverse equals I only passes when all three are done.
Dividing by a determinant that is zero because the matrix looked invertible at a glance
Fix: Compute the determinant first and stop with a stated conclusion when it vanishes, since a zero determinant rules out the inverse before any cofactor is built.
Writing (A plus B) inverse as the sum of the inverses
Fix: There is no addition rule for inverses; solve the sum with row reduction or a direct system instead of importing the scalar fraction rule.
Quoting the product rule for a pair where at least one factor is singular
Fix: Confirm both determinants are non-zero first, because the rule states a two-sided inverse and a singular factor has none.
Key Takeaways
- The inverse exists exactly when the determinant is non-zero, it is unique when it exists, and rectangular matrices are outside the definition because it demands both products.
- The adjoint is the transpose of the cofactor matrix, and the identity A times adj(A) equals determinant times I is what turns that adjoint into an inverse after one division.
- A singular matrix still has an adjoint, and that adjoint multiplies with the matrix to give zero, so the failure appears at the division step rather than earlier.
- Products reverse their order under inversion because operations are undone last-in-first-out, while sums carry no such rule and must be handled by elimination instead.