Last chapter we saw that we are able to solve linear systems with Gaussian Elimination. Now we are going to take a look at a new method which involves solving linear systems with Cramer's Rule. Cramer's Rule requires us to find the determinant of 2 x 2 and 3 x 3 matrices (depends on your linear system). However, this rule can only be used if you have the same number of equations and variables. If you have a different number of equations and variables, then finding the determinant will be impossible. Hence, it will not be possible to use Cramer's rule.

## Solving linear systems using Cramers Rule

#### What is Cramers rule

Cramers rule is a technique to solve systems of linear equations where there are the same amount of unknowns as equations in the system. The technique consists on a set of equations involving determinants and ratios in order to obtain the unique set of solutions for a linear system.

Throughout this lesson we will focus on explaining the method for solving a system that we will call Cramers rule 3x3 and Cramers rule 2x2, this means that we will focus on the cases where we have a system of equations with 3 equations for 3 unknowns (n=3) or a system with 2 equations for 2 unknowns (n=2). The reason for it is that Cramers rule is not practical when a system is of higher order than 3, other methods, such as solving a linear system with matrices using Gaussian elimination, or simply solving systems of linear equations by substitution are much more computationally effective to work through a linear system. Still Cramers rule is an important piece of linear algebra to be considered due its mathematical rigor and the deep understanding of the transcription of linear systems into matrices, and viceversa, when such systems have unique solutions.

#### How to use Cramers rule

But what is Cramers rule perse? Instead of reciting a Cramers rule definition, let us showcase the technique a little better by going through its steps in detail.

__Steps to follow when using Cramers rule linear algebra:__

1. $\enspace$ For a linear system of three equations and three unknowns and for a linear system of two equations and two unknowns, as the ones represented below:

2. $\enspace$ The system of linear equations has to be converted into and augmented matrix.

- From the augmented matrix, the elements in the left hand side of the vertical line which represents the equal sign conform a square coefficient matrix. This square coefficient matrix will be used to obtain a series of determinants in our next step.
- From the augmented matrix, the elements on the column vector on the right hand side of the equal sign will be used as replacement for certain elements when obtaining the set of determinants in the next step.
- The augmented matrices for the system with three equations and 3 unknowns and the system of two equations and two unknowns represented in equation 1 look as follows:
- Take into account that Cramers rule can be used with any system of n equations for n unknowns (as long as there are as many equations as unknowns, it doesnt matter the quantity). We have picked to represent the cases in which $\, n = 3\,$ and $\, n = 2 \,$ since those are usually the ones used before we decide to continue our calculations with a different and more convenient technique.

3. $\enspace$ Then we need to calculate $\, n+1 \,$ determinants.

- In other words, for the case in which $\, n=3 \,$, we will be calculating 4 determinants. For the case in which $\, n = 2 \,$, we will calculate 3 determinants.
- The determinants are all named based in the variables contained in the system of linear equations in question. For example, for the case in which the system has three unknowns, you have variables $x$, $y$, $z$, therefore, the determinants are: $D_x$, $D_y$, $D_z$. For the case in which the system has two unknowns, you have the variables $x$, $y$, therefore, the determinants are: $D_x$, $D_y$. Besides, in each case, there is always an extra determinant we just call $D$.
- The determinant $D$, is always the determinant of the square coefficient matrix (which we called $C$) from the left hand side of the augmented matrix. For the systems where $\, n= 3 \,$ and $\, n=2 \,$. The determinant $D$ would be as follows:
- The determinants $D_x$, $D_y$, $D_z ...$ are obtained by replacing the column vector b from equation 2, into the corresponding column on the square coefficient matrix.

_{x}, D

_{y}, D

_{z}

4. $\enspace$ Once the determinants have been calculated, we just follow the next ratio equations in order to obtain the values of the variables from the systems of equations:

In general, each equation for each variable, as shown in equation 5, is what we call the Cramers rule formula. Many books and published materials refer to this simply as Cramers rule, when in reality the technique requires multiple equations. For that same reason, sometimes you may see this technique called the matrix Cramers rule (usually referring to the augmented matrix from equation 2 or the set of determinants from equations 3 and 4).

As you can see, solving systems of equations using Cramers rule becomes very tedious very fast, and this is why this method is usually left on the side and people prefer to use techniques such as row reduction through gaussian elimination. If we compare such two methods, we can clearly see that as the system increases in number of equations, and thus unknowns, the Cramers rule matrices get bigger and the method longer since it requires n+1 amount of determinants to be solved; not only that, the determinants become bigger as n increases too.

Therefore, we are going to focus on solving systems of linear equations with up to 3 equations for 3 unknowns on this lesson, higher n values are suggested to be solved with other techniques for solving systems of linear equations.

#### Cramers rule to solve system of equations

Having explained the steps on how to do Cramers rule, let us learn how to use it while solving systems of linear equations.

We will divide this section in two parts, one dedicated to solve a system of 2 equations for 2 unknowns ($n=2$) and the other one dedicated to solve a system with 3 equations for 3 unknowns.

__Cramers rule for 2x2__

Use Cramers rule to solve the system of 2 linear equations for 2 unknowns as shown below:

We convert the system into an augmented matrix:

And then we calculate the 3 required determinants (remember that step 3 of our method dictates that we need to compute $\, n+1 \,$ determinants. For this case we have a system of 2 unknowns, thus $\, n=2 \,$, therefore $\, n+1 = 2+1 =3\,$, and so, 3 determinants to be solved).

Following equation 3, we solve the Cramers rule determinant D first:

Notice how this determinant $D$ is just the determinant of the square coefficient matrix from the left hand side of the augmented matrix in equation 7.

Now, to solve the determinants related to each of the variables in the equations from the system we need to substitute the column related to each variable in the square coefficient matrix, by the column coming from the right hand side of the augmented matrix. Thus, the determinants $D_x$, $D_y$ are:

To finally find the unique solution for each variable in the equations, we now solve the Cramers rule equation for each of them:

And so, the system has been solved! The solutions for the variables $x$ and $y$ are: $x=-7, y=5$.

Now let us take a look at the process on how to do the Cramers rule 3x3!

__Cramers rule for 3x3__

Use Cramers rule to solve the system of equations for 3 unknowns as shown below:

We convert the system into an augmented matrix:

And then we calculate the 4 required determinants. Starting with determinant $D$:

This determinant $D$ is just the determinant of the square coefficient matrix from the left hand side of the augmented matrix in equation 12.

Now, to solve the determinants related to each of the variables in the equations from the system we substitute the column related to each variable in the square coefficient matrix by the column coming from the right hand side of the augmented matrix. And so, the determinants $D_x$, $D_y$, $D_z$ are:

Solving for the variables $x$, $y$ and $z$:

And so, the system has been solved! $x=1, y=0, z=0$

In summary, in order to use Cramers rule for solving linear equations we: rewrite the system into an augmented matrix, use the left hand side of this matrix as a square coefficient matrix, and the right hand side as a substitution for the solumns related to each variable in the coefficient matrix, set up the n+1 determinants for the system, evaluate determinants and apply Cramers rule equations to find the unique solutions to the variables.

Remember, if you are not completely content with this technique you can always work through a Cramers rule proof by solving the system using any of the other techniques you already know to solve linear systems of equations.

#### Cramers rule examples

On this section we add a few other examples exercises where we use Cramers rule to solve systems of equations. We start with a few examples of 2x2 systems and end up with a 3x3 problem.

__Example 1__

Solve the following linear system using Cramers rule:
We convert the system into an augmented matrix:

And then we calculate the 3 required determinants:

Now use $D$, $D_x$, $D_y$ to finally find the unique solution for each variable in the equations:

So, the solutions for the variables $x$ and $y$ are: $x=-2.5, y=4.5$

__Example 2__

Solve the following linear system using Cramers rule:
We convert the system given above to the standard notation so we can transform it into the augmented matrix later:

We convert the system into an augmented matrix:

And then we calculate the 3 required determinants:

Now use $D$, $D_x$, $D_y$ to finally find the unique solution for each variable in the equations:

So, the solutions for the variables $x$ and $y$ are: $x=7, y=26$

__Example 3__

Solve the following linear system using Cramers rule:
We convert the system into the Cramers rule matrix (augmented matrix):

And then we calculate the 3 required determinants:

Now use $D$, $D_x$, $D_y$ to finally find the unique solution for each variable in the equations:

So, the solutions for the variables $x$ and $y$ are: $x=0, y=0$

__Example 4__

For the final Cramers rule example, we will be solving a system of 3 equations for 3 unknowns:
We convert the system into an augmented matrix:

And then we calculate the 4 required determinants:

Now use $D$, $D_x$, $D_y$ to finally find the unique solution for each variable in the equations:

And the system is solved! The solutions for the variables $x$, $y$ and $z$ are: $x=-2, y=-2, z=3$

For this last exercise we would like to work on a proof of Cramers rule by solving the system from equation 24 using another method and check for the result.

Thus, we use substitution to solve the system:

Now we continue the substitution technique by substituting the found value of the variable $z$ into the first and second equations and obtain a new simplified system of 2 equations for 2 unknowns:

Using these new expressions found in equation 29, solve for x in the second equation and substitute it in the first equation to find $y$:

And we finalize this by substituting the found value of y into the second expression from equation 29:

The final found values for the variables $x$,$y$ and $z$ are: $x=-2, y=-2, z=3$

Therefore, the unique solutions for the variables in the linear system of equations match with the answers found using Cramers rule for matrices! And you can clearly see that both approaches are good for us to use when solving systems.

To finalize our lesson of today, as always, we have a few recommendations for your further studies. First, this detailed article in which you can find an example of using Cramers rule to solve two equations with two unknowns. And then, this link on the inverse matrix and Cramers rule where you can find an example of a 3x3 system in the bottom.

This is it for this lesson, see you in the next one!

This is a different way of solving linear systems. Instead of using Gaussian Eliminations, you can use Cramer's Rule! Make sure to review your determinants of 2 x 2 and 3 x 3 matrices.

Cramer's Rule for 2 x 2 matrices:

$x=\frac{D_x}{D}$

$y=\frac{D_y}{D}$

Cramer's Rule for 3 x 3 matrices:

$x=\frac{D_x}{D}$

$y=\frac{D_y}{D}$

$z=\frac{D_z}{D}$

Cramer's Rule for 2 x 2 matrices:

$x=\frac{D_x}{D}$

$y=\frac{D_y}{D}$

Cramer's Rule for 3 x 3 matrices:

$x=\frac{D_x}{D}$

$y=\frac{D_y}{D}$

$z=\frac{D_z}{D}$