Welcome to the Cramer's rule calculator, a quick and easy 2- and 3-variable system of equations solver. Together, we'll learn how to construct a coefficient matrix and then try using those matrices to solve systems of equations. You might have already seen one or two different ways to tackle similar mathematical problems. However, we're here to convince you that Cramer's rule for 3x3 matrices is almost as easy as Cramer's rule for 2x2 matrices (which is super easy)!

So, would you like to learn how to solve systems of equations with a matrix or two, without any substitution, elimination, or drawing graphs - just simple arithmetics?

Using matrices to solve systems of equations is worthwhile.

What is a system of equations?

You know how not everything in life is known, or easy to describe? Like how fast does the universe expand, how much can you save on Black Friday, or how many apples did Mr. Smith buy if he paid $3.50 and one costs $0.50? You know, the essential questions in life.

Whenever we don't know some number explicitly, but we can describe it in relation to some other numbers, we obtain an equation. Mathematically speaking, it's a symbolic description of an equality that our value must satisfy. For example, we can write the third question as follows:

cost_of_one_apple * $0.50 = $3.50.

The cost_of_one_apple is the value that we don't know and would like to find. Usually, we call such a thing a variable and denote it by a single letter, say, x. The equation above then looks like this:

x * $0.50 = $3.50.

That's a pretty simple one, and we can easily calculate that Mr. Smith bought seven apples. However, life is not always that easy. Not only can Mr. Smith buy more apples, but he can also, for example, give a tip to the shopkeeper. We would then have to include that in the equation we construct, which would make it a little more complicated. But what if Mr. Smith wants to buy some oranges as well?

If a new value enters the picture and we don't know it either, we must introduce it as a new variable, say y. When we describe our two variable question, what we get is still an equation, however, in general, they become more difficult to calculate.

Nevertheless, if we have more information, the problem looks much more promising. For instance, if on one occasion Mr. Smith bought 7 apples and 3 oranges and paid $5.60, and on another he bought 1 apple and 5 oranges, and paid $4.00, then this is enough information to calculate how much an apple and an orange cost. This is because we can write two equations (one for each shopping) with two variables. We call such a thing a system of equations.

To sum up, in general, a system of equations is a number of equations with a few variables, and we want to find numbers that satisfy all of these equations. We will now describe how to solve such a system of equations with a matrix.

Using matrices to solve systems of equations

Let's look at a traveling-themed problem:

An example of a system of equations.

At first, it may not look like a system of equations, but in fact, it is just that. After all, the x's and y's we used in the section above are just examples of how we can denote a variable; there is no reason why we can't use bikes instead.

However, for simplicity of notation, and for the sake of our 3-variable system of equations solver, let's switch to the boring mathematical notation, and say that x will denote the bike, y the car, and z the plane. Then we can write the above system as

x + y + z = 26;

y - z - z = 6; and

x + x - z = 12.

We have three equations and three variables, so our end-goal is to use Cramer's rule for 3x3 matrices (the first 3 denote the number of equations, the second the number of variables). To do this, we first need to construct an array of numbers, which we'll call the coefficient matrix.

Before that, however, we have to work a little to make our system more like the one we see in our Cramer's rule calculator. Note, that we can simplify the two last equations, i.e., add together the same variables in each line. For example, in the bottom equation, we have x + x, which we can write as 2x (one copy of x plus one copy of x equals two copies of x). All in all, we obtain

x + y + z = 26

y - 2z = 6

2x - z = 12.

Now we're ready to form the coefficient matrix. It will be an array with three rows (because we have three equations) and three columns (because we have three coefficients). The first column will correspond to the variable x, the second to y, and the third to z. Here, by "correspond," we mean that it will contain the coefficients of that variable in consecutive equations (hence the name coefficient matrix). Note, that we don't have all the variables in all the lines. For example, the second equation doesn't have the x variable. Fortunately, this simply means that the coefficient of x in that line is, in fact, zero.

To sum up, the number in row i and column j in the coefficient matrix contains the number next to j-th coefficient (the first being x, the second y, and the third z) in the i-th equation. In our case, it will look as follows:

1 1 1
| 0 1 -2
2 0 -1

Quite often, it is useful to define the so-called augmented coefficient matrix. It is the same thing with an additional column to the right, with the right hand side numbers of the equalities of our system. Usually, it is separated from the others by a dashed line. In our case, it looks like this:

1 1 1 26
| 0 1 -2 6
2 0 -1 12

Let's not waste a minute more and start using these matrices to solve systems of equations using Cramer's rule for 3x3 systems.

Cramer's rule for 2x2 and 3x3 systems

Most of the ways of dealing with systems of equations is to change the system itself a lot - reducing its rows, substituting one value for another, and so on. It tends to get messy in more complicated examples. Cramer's rule is a way to hide all of that with a few simple arithmetic operations on the coefficient matrix, namely calculating a few determinants.

The determinant of a square matrix is a number that we get from multiplying and adding some of the cells of the matrix. Since our Cramer's rule calculator is a 2- and 3-variable system of equations solver, we'll focus on the formulas for when we have two equations with two variables and three equations with three variables.

If

A =
a b
c d

then the determinant of A, denoted |A| or det(A), is

|A| = a*d - b*c.

And if

a b c
B = | d e f
g h i

then the determinant of B is

|B| = a*e*i + b*f*g + c*d*h - c*e*g - b*d*i - a*f*h.

Now denote the coefficient matrix of our system by W (note, that it is a 2x2 matrix when we have two equations and two variables, and 3x3 when we have three equations and three variables). We will now define some additional matrices, Wₓ, Wᵧ, and Wz, that will correspond to each variable of our system (Wz exists only when we have z in the equations).

Recall the augmented coefficient matrix from the section above. It had an additional column with the numbers on the right hand side of the = sign in the system. We define the matrices corresponding to variables to be the initial coefficient matrix with the column of the variable in question swapped for the extra, right hand side column. For instance, the matrix Wz will have the same first two columns (corresponding to x and y) as W, while its third column will be the additional one from the augmented coefficient matrix.

The Cramer's rule for 2x2 systems states that the system's solution is given by

x = |Wₓ| / |W| and

y = |Wᵧ| / |W|,

and the Cramer's rule for 3x3 systems adds to that a third variable:

z = |Wz| / |W|.

Note, that when we use these formulas to solve a system of equations, each matrix mentioned above is 2x2 in size when we have two equations and two variables, and 3x3 in size when we have three equations and three variables.

Things to remember:

  • Using matrices to solve systems of equations with Cramer's rule allows us to find the answer by simply following a few predetermined calculations. There is almost no thinking here, only multiplication, addition, and division;
  • We can use the above description as a step-by-step 2- and 3-variable system of equations solver. However, Cramer's rule still applies to larger matrices, although the calculations can get a little messy. In particular, the determinant gets pretty ugly. The number of summands in the formula is equal to the number of permutations. This means that for four equations with four variables, it has 24, and for five, it has 120 summands;
  • The determinant of a matrix can be zero. If it's the W matrix, then we have a problem: we cannot divide by zero! This can mean two things: either we have no solutions, or we have infinitely many of them. The first case is when at least one of the variable matrices is non-zero, and the latter when all of them are zero (together with W);
  • Our Cramer's rule calculator will tell you if we're dealing with one of the two special cases we've mentioned above. Even better, if there are infinitely many solutions, it will also describe the form of the pairs/triples that satisfy the system; and
  • Try to get a decent amount of sleep every day. It's always good to remember that.

Example: using the Cramer's rule calculator

Recall the traveling-based example from section two and the system of equations that we got from it after simplifying each line:

x + y + z = 26;

y - 2z = 6; and

2x - z = 12.

Let's also remind ourselves of the augmented coefficient matrix:

1 1 1 26
| 0 1 -2 6
2 0 -1 12

Before we move on to construct the four matrices used in Cramer's rule for 3x3 systems, let's take some time to describe how we can input the data into the Cramer's rule calculator.

We have three equations to deal with, so let's tell the calculator that by choosing the right option in the "Number of equations" field. This will turn our tool into a 3-variable system of equations solver and show us a picture of what such a system looks like, with a few mysterious symbols, like a₁ or c₂. These denote the coefficients of our system, i.e., the numbers that stand to the left of the variables in each line and the numbers to the right of the = sign.

This notation is listed in the calculator, where you can input the values from the problem that you want to solve. The a's correspond to the numbers next to x's, the b's to y's, the c's to z's, the d's are the numbers on the right, and the indices tell us the number of the row. Note that our Cramer's rule calculator accepts only linear equations. This means that we cannot, for example, have a quadratic one, or an expression with a variable under a square root.

Observe that those coefficients are also in our augmented coefficient matrix. In fact, it is enough to copy them into the Cramer's rule calculator. For example, the first row of the matrix has numbers 1, 1, 1, and 26. It corresponds to the first equation, which has coefficients denoted with the subscript . Therefore, we have:

a₁ = 1, b₁ = 1, c₁ = 1, d₁ = 26.

Similarly, the other two rows give us:

a₂ = 0, b₂ = 1, c₂ = -2, d₂ = 6; and

a₃ = 2, b₃ = 0, c₃ = -1, d₃ = 12.

Once you get all that data into the Cramer's rule calculator, it should spit out the values of the four determinants, followed by the solution to the system. Let's look how it figured that out.

As we've mentioned in the section above, Cramer's rule for 2x2 and 3x3 systems means that we have to calculate the determinants of a few matrices. The first one, the so-called main one, is simply the coefficient matrix that we've defined in section two:

1 1 1
W = | 0 1 -2
2 0 -1

To construct the other three, we'll need to exchange one column of this matrix with the fourth extra column of the augmented coefficient matrix, which in our case has numbers 26, 6, and 12. To get Wₓ, the x matrix, we put those numbers instead of the column corresponding to the x variable, namely the first one:

26 1 1
Wₓ = | 6 1 -2
12 0 -1

Similarly, we get

1 26 1
Wᵧ = | 0 6 -2
2 12 -1
1 1 26
Wz = | 0 1 6
2 0 12

All we need to do is use the determinant formula from the section above for all four of the matrices:

|W| = 1*1*(-1) + 1*(-2)*2 + 1*0*0 - 1*1*2 - 1*0*(-1) - 1*(-2)*0 = -7,

|Wₓ| = 26*1*(-1) + 1*(-2)*12 + 1*6*0 - 1*1*26 - 1*6*(-1) - 26*(-2)*0 = -56,

|Wᵧ| = 1*26*(-1) + 26*(-2)*2 + 1*0*12 - 1*6*2 - 26*0*(-1) - 1*(-2)*12 = -98,

|Wz| = 1112 + 162 + 2600 - 2612 - 1012 - 160 = -28.

Lastly, we use Cramer's rule for 3x3 systems and obtain the solution:

x = |Wₓ| / |W| = -56 / (-7) = 8,

y = |Wᵧ| / |W| = -98 / (-7) = 14,

z = |Wz| / |W| = -28 / (-7) = 4.

Going back to the problem we started with, this means that the bike is equal to 8, the car is equal to 14, and the plane is equal to 4.

It makes you want to do some traveling, doesn't it?

Maciej Kowalski, PhD candidate