Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 8

Inverting Matrices

Recommended resources

Welcome to the final lesson in our module on linear algebra foundations. In our previous session, we tackled solving systems of linear equations, . We saw that if a matrix is invertible, we can find a unique solution using its inverse, . We also learned the powerful and general Gaussian elimination algorithm to solve any system.

Today, we'll dive deep into the matrix inverse itself. While we've used it conceptually, this lesson focuses on the practical questions: What exactly is an inverse? When does it exist? And, most importantly, how do we compute it? Mastering this will solidify your understanding of linear transformations and prepare you for more advanced topics in machine learning.

1. The Inverse: Undoing a Transformation

At its core, the inverse of a matrix is an "undo" button. If a matrix represents a transformation that takes an input vector to an output vector , its inverse, , is the transformation that takes right back to .

To build a strong intuition for this, let's start with a practical example that frames this concept in a business context.

What is the Inverse of a Matrix ??? : Data Science Basics

The video "What is the Inverse of a Matrix ???" from ritvikmath uses a great story about a band's profits to explain the purpose of an inverse.

First, watch the setup from the beginning. The speaker establishes a matrix equation P * f = m, where P is a profit matrix, f is a vector of multipliers, and m is the final money earned. This is a classic forward problem. Then, watch the explanation of the inverse question. This is the crucial part. The problem is flipped: if we have a target amount of money m, what multipliers f do we need? This leads to the discovery of an inverse matrix V (which he later calls P⁻¹) that solves this reverse problem.

As the video demonstrates, if applying matrix gets us from f to m, there must be an inverse matrix that gets us from m back to f. When we combine these two operations, we should end up exactly where we started. This leads to the formal definition of the inverse.

Definition of a Matrix Inverse

For a square matrix , its inverse is a matrix that satisfies the following condition:

where is the identity matrix—a square matrix with ones on the main diagonal and zeros everywhere else. Applying the identity matrix to any vector leaves the vector unchanged.


2. Conditions for Invertibility

Not all matrices have an inverse. A matrix that has an inverse is called invertible or non-singular. A matrix that does not is called singular. For a matrix to be invertible, it must satisfy two key conditions.

What is Inverse of a Matrix - Formula, Properties & Guide

This article section clearly states the conditions for invertibility.

Read the section "When Does a Matrix have an Inverse? Determinant not Equal to Zero". It succinctly presents the two rules and gives quick examples.

As you just read, the two conditions are:

  1. The matrix must be square. It must have the same number of rows and columns ().
  2. The determinant of the matrix must be non-zero ().

Let's briefly revisit the intuition for these rules:

  • Why square? A linear transformation maps an input space to an output space. An inverse must map that output space back to the original input space. The ritvikmath video's analogy of mapping between "small" and "large" spaces gave a great feel for this. A unique, well-defined inverse generally only exists when the input and output spaces have the same dimension, which corresponds to a square matrix.

  • Why non-zero determinant? As we saw in previous lessons, a zero determinant means the transformation squishes space into a lower dimension (e.g., a plane collapses into a line). As 3Blue1Brown explained, you cannot "un-squish" a line back into a plane with a function, because a single input would need to map to multiple outputs. An inverse function can't exist.

Inverse matrices, column space and null space | Chapter 7, Essence of linear algebra

Let's quickly review the geometric reason for the non-zero determinant condition from 3Blue1Brown's "Essence of linear algebra" series.

Watch the short segment on the zero-determinant case. This visually reinforces why an inverse is impossible when a transformation is irreversible.


3. How to Compute the Inverse

Now for the main event: calculating . The method depends on the size of the matrix.

The 2x2 Case: A Simple Formula

For a 2x2 matrix, there is a convenient formula.

What is Inverse of a Matrix - Formula, Properties & Guide

This article provides the direct formula for a 2x2 inverse.

Focus on the section "Inverse of a 2×2 Matrix" to learn the formula and see a worked example.

For a matrix , the inverse is:

Example: Let's find the inverse of .

  1. Compute the determinant: .
    Since , the inverse exists.
  2. Apply the formula:

The n x n Case: Gauss-Jordan Elimination

For matrices larger than 2x2, the formulaic approach becomes unwieldy. The standard algorithm is Gauss-Jordan elimination, which is a direct extension of the Gaussian elimination you learned in the last lesson.

The procedure is as follows:

  1. Create an augmented matrix by placing the identity matrix to the right of your matrix . This looks like .
  2. Use the three elementary row operations (swapping rows, multiplying a row by a non-zero scalar, adding a multiple of one row to another) to transform the left side () into the identity matrix .
  3. As you perform these operations, the right side () will be transformed into . The final form will be .

Let's walk through an example. Find the inverse of . (This is an upper-triangular matrix, which simplifies the process).

  1. Set up the augmented matrix:
  2. Goal: Transform the left side into . We need to create zeros above the main diagonal. We'll work from bottom to top.
    • Row 3 is already good. We have a 1 in the pivot position.
    • Eliminate the 4 in R2 C3. Use the pivot in R3. Operation: .
    • Eliminate the 3 in R1 C3. Operation: .
    • Now, eliminate the 2 in R1 C2. Use the pivot in R2. Operation: .

The left side is now the identity matrix. The right side is our inverse.

Verification:
An essential final step is to check your work. If you multiply by your computed , you should get the identity matrix.

It works!

The Adjoint Method (A Brief Mention)

Another method you may see in textbooks is the Adjoint method. It involves calculating the determinant, a matrix of cofactors, and the transpose of that matrix (the adjoint).

This image outlines the components needed for the Adjoint method: calculating the determinant, the cofactor matrix, and the adjoint (transpose of cofactors) to find the inverse.

While correct, this method is computationally very expensive for matrices larger than 3x3. For practical purposes, especially in computing and machine learning, Gauss-Jordan elimination is the standard and more efficient technique.


4. Key Properties of Matrix Inverses

Finally, here are a few essential properties of inverses that are useful in algebraic manipulations.

If and are invertible matrices of the same size, and is a non-zero scalar:

  • The inverse of the inverse is the original matrix:
  • The inverse of a product is the product of the inverses in reverse order:
  • The inverse of a transpose is the transpose of the inverse:
  • The inverse of a matrix scaled by :

Conclusion

In this lesson, you have closed the loop on matrix inverses. You now understand what they represent, the conditions under which they exist, and how to compute them.

Key Takeaways:

  • The inverse matrix reverses the linear transformation performed by matrix , satisfying .
  • A matrix is invertible if and only if it is square and its determinant is non-zero.
  • The inverse of a 2x2 matrix can be found with a simple formula.
  • For any n x n matrix, Gauss-Jordan elimination is the standard, efficient algorithm for finding the inverse by transforming the augmented matrix into .
  • Always verify your computed inverse by checking if .

This lesson marks the end of our first module on Linear Algebra Foundations. You've refreshed your knowledge of vectors, matrices, determinants, and inverses—the essential building blocks. In the next module, we will use these tools to explore matrix decompositions. We'll begin with one of the most important concepts in all of linear algebra: eigenvalues and eigenvectors. These special vectors reveal the intrinsic behavior of a matrix transformation and are the mathematical heart of powerful ML techniques like Principal Component Analysis (PCA).