# Inverse Matrix Calculator

Welcome to the **inverse matrix calculator**, where you'll have the chance to learn all about inverting matrices. This operation is similar to searching for the fraction of a given number, except now we're multiplying matrices and want to **obtain the identity matrix as a result**.

But don't worry. Before we give, say, the inverse of a $4\times4$ matrix, we'll look at some basic definitions, including a **singular and nonsingular matrix**. Then we'll move on to the general **inverse matrix formula** with a neat simplification for the inverse of a $2\times2$ matrix and some useful matrix inverse properties. Last but not least, we give an example with thorough calculations of how to find the inverse of a $3\times3$ matrix.

## What is a matrix?

In primary school, they teach you the **natural numbers**, $1$, $2$, or $143$, and they make perfect sense – you have $1$ toy car, $2$ comic books, and terribly long $143$ days until Christmas. Then they tell you that there are also fractions (or **rational numbers**, as they call them), such as $1/2$, or decimals, like $1.25$, which still seems reasonable. After all, you gave $1/2$ of your chocolate bar to your brother, and it cost $\text{\textdollar}1.25$. Next, you meet the **negative numbers** like $-2$ or $-30$, and they're a bit harder to grasp. But, once you think about it, one guy from your class got $-2$ points on a test for cheating, and there was a $-\text{\textdollar}30$ discount on jeans on Black Friday.

Lastly, the school introduces **real numbers** and some weird worm-like symbols that they keep calling square roots. What's even worse, while $\sqrt{4}$ is a simple $2$, $\sqrt{3}$ is something like $1.73205...$ and the digits go on forever. They convince you that such numbers describe, for example, the diagonal of a rectangle. And then there's $\pi$, which somehow appeared out of nowhere when you talked about circles. Fair enough, maybe those numbers are *real* in some sense. But **that's just about as far as it can go**, right?

**Wrong.** Mathematicians are busy figuring out various interesting and, believe it or not, **useful extensions of real numbers**. The most important one is complex numbers, which are the starting point for any modern physicist. Fortunately, that's not the direction we're taking here. **There is another.**

**A matrix is an array of elements** (usually numbers) **that has a set number of rows and columns.** An example of a matrix would be:

Moreover, we say that a matrix has **cells**, or **boxes**, in which we write the elements of our array. For example, matrix $A$ above has the value $2$ in the cell that is **in the second row and the second column**. The starting point here is 1-cell matrices, which are basically the same thing as real numbers.

As you can see, matrices are a tool used to **write a few numbers concisely and operate with the whole lot as a single object**. As such, they are extremely useful when dealing with:

- Systems of equations, especially when using Cramer's rule or as we've seen in our condition numbers calculator;
- Vectors and vector spaces;
- 3-dimensional geometry (e.g., the dot product and the cross product);
- Eigenvalues and eigenvectors; and
- graph theory and discrete mathematics.

Calculations with matrices are **a great deal trickier than with numbers**. For instance, if we want to add them, we first have to make sure that we can. But, since we're here on the **inverse matrix calculator**, we leave addition for later. First, however, let's familiarize ourselves with a few definitions.

## Singular and nonsingular matrix, the identity matrix

Whether you want to find the inverse of a $2\times2$ matrix or the inverse of a $4\times4$ matrix, you have to understand one thing first: **it doesn't always exist**. Think of a fraction, say $a / b$. Such a thing is perfectly fine **as long as** $b$ **is non-zero**. If it is, the expression doesn't make sense, and a similar thing happens for matrices.

A **singular matrix** is one that doesn't have an inverse. A **nonsingular matrix** is (surprise, surprise) one that does. Therefore, whenever you face an exercise with an inverse matrix, you should begin by checking if it's nonsingular. Otherwise, there's no point sweating over calculations. **It just cannot be done.**

You can still get **pretty close** to a singular matrix's inverse by instead calculating its Moore-Penrose pseudoinverse. If you don't know what the pseudoinverse is, wait no more and jump to the pseudoinverse calculator!

By definition, **the inverse of a matrix** $A$ is a matrix $A^{-1}$ for which:

Where $\mathbb{I}$denotes **the identity matrix**, i.e., a square matrix that has $1$s on the main diagonal and $0$s elsewhere. For example, the $3\times3$ identity matrix is:

In other words, when given an arbitrary matrix $A$, we want to find another one for which **the product of the two** (in whatever order) **gives the identity matrix**. Think of $\mathbb{I}$ as $1$ (the identity element) in the world of matrices. After all, for a fraction $a / b$, its inverse is $b / a$ but not just because we "*flip it*" (at least, not by definition). It's because of a similar multiplication property:

That was enough time spent reading through definitions, don't you think? Let's finally see **the inverse matrix formula** and learn how to find the inverse of a $2\times2$, $3\times3$, and $4\times4$ matrix.

## How to find the inverse of a matrix: inverse matrix formula

Before we go into special cases, like the inverse of a $2\times2$ matrix, let's take a look at **the general definition**.

Let $A$ be a square nonsingular matrix of size $n$. Then the inverse $A^{-1}$ (if it exists) is given by the formula:

The $|A|$ is the determinant of $A$ (not to be confused with the absolute value of a number). The $A_{ij}$ denotes the $i,j$-minor of $A$, i.e., the determinant of the matrix obtained from $A$ by forgetting about its $i^{\mathrm{th}}$ row and $j^{\mathrm{th}}$ column (it is a square matrix of size $n-1$). What we have obtained in called the *cofactor matrix* of $A$. Lastly, the $^{\mathrm{T}}$ outside the array is the transposition. It means that once we know the cells inside, we have to "*flip them*" so that the $i^{\mathrm{th}}$ row will become its $i^{\mathrm{th}}$h column and vice versa, as we taught you at the matrix transpose calculator. This leads to the *adjoint matrix* of $A$. All these steps are detailed at Omni's adjoint matrix calculator, in case you need a more formal explanation.

Phew, that was **a lot of symbols and a lot of technical mumbo-jumbo**, but that's just the way mathematicians like it. Some of us wind down by watching romcoms, and others write down definitions that sound smart. **Who are we to judge them?**

In the next section, we point out **a few important facts to take into account** when looking for the inverse of a $4\times4$ matrix, or whatever size it is. But before we see them, let's take some time to look at **what the above matrix inverse formula becomes** when it's the inverse of a $2\times2$ matrix that we're looking for.

Let:

Then the minors (the $A_{ij}$s above) come from crossing out one of the rows and one of the columns. But if we do that, we'll be left with **a single cell**! And the determinant of such a thing (a $1\times1$ matrix) is just the number in that cell. For example, $A_{12}$ comes from forgetting the first row and the second column, which means that only $c$ remains (or rather $\begin{pmatrix}c\end{pmatrix}$ since it's a matrix). Therefore,

Also, in this special case, **the determinant is simple enough**: $|A| = a\times d - b\times c$. So after taking the minuses and the transposition, we arrive at **a nice and pretty formula** for the inverse of a $2\times2$ matrix:

Arguably, the inverse of a $4\times4$ matrix is not as easy to calculate as the $2\times2$ case. **There is an alternative way of calculating the inverse of a matrix**; the method involves **elementary row operations** and the so-called **Gaussian elimination** (for more information, be sure to check out the (reduced) row echelon form calculator). As an example, we describe below how to find the inverse of a $3\times3$ matrix using the alternative algorithm.

Say that you want to calculate the inverse of a matrix:

We then construct a matrix with three rows and twice as many columns like the one below:

and use Gaussian elimination on the 6-element rows of the matrix to transform it into something of the form:

where the $x$'s, $y$'s, and $z$'s are obtained along the way from the transformations. Then:

Whichever method you prefer, it might be useful to check out a few **matrix inverse properties** to make our studies a little easier.