It’s Professor Dave, let’s learn Cramer’s Rule.
By now we are quite familiar with systems of linear equations, as well as a couple of
ways to go about solving them.
But now that we have also learned how to find the determinant of a square matrix, we are
ready to learn a totally new way to solve these systems, so let’s do that now.
Say we have the following generalized system of equations to solve.
We know that we can do Gauss-Jordan elimination, but if we don’t feel like doing that, there
is another way, and that’s something called “Cramer’s Rule”.
This rule involves setting up the coefficient matrix that corresponds to the system, and
replacing certain columns with the constant terms that are shown on the right side of
each equation.
The rule states that the i-th component of the solution, meaning a particular one of
these variables, can be found by taking the determinant of the matrix with the i-th column
replaced by the constant terms, and then dividing that by the determinant of the coefficient matrix.
So if we wanted to solve for the first variable, X1, we would replace the first column with
these constants to get matrix A1.
If we wanted to solve for the second variable, X2, we would replace the second column with
these constants to get matrix A2, and so forth.
Let’s take this pair of equations and run through a simple example.
Setting up the coefficient matrix, we get 1 and 3 on the top row, and then 2 and 2 on
the bottom row.
Let’s go ahead and find the determinant of this matrix, as the determinant of the
coefficient matrix will be used no matter which variable we solve for.
If you need to remember how to do that, check out my previous tutorial on this subject,
otherwise let’s just multiply the 1 in the top left by the 2 in the bottom right, and
then subtract from that the product of the 3 in the top right and the 2 in the bottom left.
This gives us 2 minus 6, or negative 4.
Now let’s talk about the matrix that goes on top.
For the first variable, X1, we will have to replace the first column of the coefficient
matrix with the constants, 5 and 6, that we see on the right side of these equations,
and then we will find the determinant of this new matrix.
This will be five times two, minus the quantity six times three, or ten minus eighteen, which
is negative eight.
Then to solve for X1, we simply divide the determinant of the altered matrix by the determinant
of the coefficient matrix, which we already calculated, and negative eight divided by
negative four gives us a value of two for X1.
Now let’s solve for the second variable, X2.
To do this, it’s almost the same thing, the only difference is that we will replace
the second column of the coefficient matrix with 5 and 6, rather than the first, because
we are solving for the second variable.
Now we can find the determinant of this matrix.
This time we get one times six minus the quantity two times five, or six minus ten, which is
negative four.
So we can take that and divide by negative four, just like we did for the first variable,
because the determinant of the original coefficient matrix didn’t change at all, and negative
four divided by negative four gives us a value of 1 one for X2.
And there we have our solution for this system of equations, X1 equals 2 and X2 equals 1.
If we wish, we can plug these values into the original equation to verify that they
work, and in turn that this algorithm worked nicely.
Now we might wonder why we would want to use this, as it seems like a lot of work, when
we could have solved this very quickly by substitution or elimination.
But the thing to remember is that systems of equations can get very complicated, and
solving ten equations with ten variables won’t seem so easy by previous methods.
Cramer’s Rule is a simple algorithm that works precisely the same way for any number
of equations with that same number of variables, so long as the system has a unique solution.
If the coefficient matrix has a determinant of zero, we will not be able to use this rule,
as there is not one unique solution.
But this is easy to spot, as we would need to divide by zero when solving for any variable,
and of course that’s not possible.
Now that we are warmed up, let’s look at another example, this time with three equations
and three unknowns.
First let’s set up the coefficient matrix and find its determinant.
If you need to practice finding the determinant of a three by three matrix, go back to that
tutorial now, otherwise here we will just skip ahead to knowing that the answer is 12.
Now let’s set up the three other matrices that will be involved in the rule.
Replacing the first column with the constant terms will give us A1, and this matrix has
a determinant of 24.
Replacing the second column with the constant terms will give us A2, and this matrix has
a determinant of 12.
Then we can do the same thing for the third column to get A3, which has a determinant
of -48.
With these determinants calculated, solving for the variables will be trivial.
For X1 we take 24 and divide by 12 to get 2.
For X2, 12 divided by 12 gives us one.
And then for X3, -48 divided by 12 will give us negative 4.
And there is our solution to this system of equations.
With this new and nifty trick under our belts, let’s check comprehension.