Cramer’s Rule for a 3×3 System (with Three Variables)

In our previous lesson, we studied how to use Cramer’s Rule with two variables.  Our goal here is to expand the application of Cramer’s Rule to three variables usually in terms of [latex]\large{x}[/latex], [latex]\large{y}[/latex], and [latex]\large{z}[/latex]. I will go over five (5) worked examples to help you get familiar with this concept.

To do well on this topic, you need to have an idea of how to find the determinant of a 3⨉3 matrix. So, this is what we are going to do first. Ready?

Formula to Find the Determinant of a 3⨉3 Matrix

  • Given a 3⨉3 matrix 
Matrix A is a 3 by 3 square matrix with elemenys a, b and c on the first row, elements d, e and f on the second row, and elements g, h and i on the third row. We can write Matrix in compact for as A = [a,b,c;d,e,f;g,h,i].
  • Its determinant can be calculated using the following formula.
The determinant of matrix A = [a,b,c;d,e,f;g,h,i] is calculated as as follows: |A| = a times the determinant of matrix [e,f;h,i] minus b times the determinant of matrix [d,f;g,i] plus c times the determinant of matrix [d,e;g,h]. In compact form, the determinat of matrix A is |A| = a*|e,g;h,i| - b*|d,f;g,i| + c*|d,e;g,h|.

Let’s do a quick example of this.

Find the determinant of matrix A

Matrix A is a 3x3 square matrix with entries 6, 2 and -4 on its first row, entries 5, 6 and -2 on its second row, and entries 5,2 and -3 on its third row. Therefore we can write matrix A as A = [6,2,-4;5,6,-2;5,2;-3].

Solution: Make sure that you follow the formula on how to find the determinant of a 3×3 matrix carefully, as shown above. More so, don’t rush when you perform the required arithmetic operations in every step. This is where common errors usually occur, but it can be prevented. When you do it right, your solution should be similar to the one below.

To find the determinant of the square (3 by 3) matrix A = [6,2,-4;5,6,-2;5,2,-3], we have the following steps: |A|=|6,2,-4;5,6,-2;5,2,-3|=6*|6,-2;2,-3| - (2)*|5,-2;5,-3|+(-4)*|5,6;5,2| = 6(-14) - 2(-5) - 4(-20) = -84 +10 + 80 = 6. Therefore, the determinant of matrix A is equal to 6.

Now, it’s time to go over the procedure on how to use Cramer’s Rule in a linear system involving three variables.

Cramer’s Rules for Systems of Linear Equations with Three Variables

  • Given a linear system
This is the general form of a system of linear equations with three (3) variables. The equations are a1x+b1y+c1z=d1, a2x+b2y+c1z=d2, a3x+b3y+c3z=d3. The x-column contains the constants a1, a2 and a3. The y-column contains the constants b1, b2, and b3. Finally, the z-column has the contants c1, c2, and c3. Moreso the constant column is the column to the right of the equal symbol. Therefore, the constant-column has the constants d1, d2, and d3.
  • Labeling each of the four matrices

coefficient matrix:  

The coefficient-matrix D is a square matrix with elements a1,b1 and c1 on the first row; elements a2, b2 and c2; and elements a3, b3 and c3. We can write coefficient-matrix D in compact form as D = [a1,b1,c1;a2,b2,c2;a3,b3,c3].

X – matrix:  

The x-matrix D is a square matrix with elements d1,b1 and c1 on the first row; elements d2, b2 and c2; and elements d3, b3 and c3. X-matrix D can be written as Dx = [d1,b1,c1;d2,b2,c2;d3,b3,c3].

Y – matrix:  

The y-matrix D is a square matrix with elements a1,d1 and c1 on the first row; elements a2,d2 and c2; and elements a3, d3 and c3. Y-matrix D can be written as Dy = [a1,d1,c1;a2,d2,c2;a3,d3,c3].

Z – matrix:  

The z-matrix D is a square matrix with elements a1,b1 and d1 on the first row; elements a2,b2 and d2; and elements a3, b3 and d3. Z-matrix D can be written as Dz = [a1,b1,d1;a2,b2,d2;a3,b3,d3].
  • To solve for [latex]x[/latex]:
To solve for x, the formula is, x = |Dx|/|D| = (determinant of x-matrix D) divided by (determinant of coefficient matrix D) = |d1,b1,c1;d2,b2,c2;d3,b3,c3| / |a1,b1,c1;a2,b2,c2;a3,b3,c3|.
  • To solve for [latex]y[/latex]:
To solve for y, the formula is, y = |Dy|/|D| = (determinant of y-matrix D) divided by (determinant of coefficient matrix D) = |a1,d1,c1;a2,d2,c2;a3,d3,c3| / |a1,b1,c1;a2,b2,c2;a3,b3,c3|.
  • To solve for [latex]z[/latex]:
To solve for z, the formula is, z = |Dz|/|D| = (determinant of z-matrix D) divided by (determinant of coefficient matrix D) = |a1,b1,d1;a2,b2,d2;a3,b3,d3| / |a1,b1,c1;a2,b2,c2;a3,b3,c3|.

Things to observe from the setup above:

1) The coefficients of variables [latex]x[/latex], [latex]y[/latex], and [latex]z[/latex] make use of subscripted [latex]a[/latex], [latex]b[/latex], and [latex]c[/latex], respectively. While the constant terms use subscripted [latex]d[/latex].

2) The denominators to find the values of [latex]x[/latex], [latex]y[/latex], and [latex]z[/latex] are all the same which is the determinant of the coefficient matrix (coefficients coming from the columns of [latex]x[/latex], [latex]y[/latex], and [latex]z[/latex]).

3) To solve for [latex]x[/latex], the coefficients of the [latex]x-[/latex]column is replaced by the constant column (in red).

4) To solve for [latex]y[/latex], the coefficients of the [latex]y-[/latex]column is replaced by the constant column (in red).

5) In the same manner, to solve for [latex]z[/latex], the coefficients of the [latex]z-[/latex]column is replaced by the constant column (in red).


Examples of How to Solve Systems of Linear Equations with Three Variables using Cramer’s Rule

Example 1: Solve the system with three variables by Cramer’s Rule.

the system of equations with three (3) variables are x+2y+3z=-5, 3x+y-3z=4 and -3x+4y+7z=-7

From the given system of linear equations, I will construct the four matrices that will be used to solve for the values of [latex]\large{\color{green}x}[/latex], [latex]\large{\color{green}y}[/latex], and [latex]\large{\color{green}z}[/latex].

Use the guide above to correctly set up these special matrices.

  • coefficient matrix
The coefficient matrix D has entries 1, 2 and 3 on its first row; entries 3, 1 and -3 on its second row; -3, 4 and 7 on its third row. This can be expressed as D = [1,2,3;3,1,-3;-3,4,7].
  • X – matrix
The x-matrix D has entries -5, 2 and 3 on its first row; entries 4, 1 and -3 on its second row; -7, 4 and 7 on its third row. This can be expressed as Dx = [-5,2,3;4,1,-3;-7,4,7].
  • Y – matrix
The y-matrix D has entries 1, -5 and 3 on its first row; entries 3, 4 and -3 on its second row; -3, -7 and 7 on its third row which can be expressed symbolically as Dy = [1,-5,3;3,4,-3;-3,-7,7].
  • Z – matrix
The z-matrix D has elements 1, 2 and -5 on the first row; elements 3, 1 and 4 on the second row; -3, 4 and -7 on the third row. This can be written in math form as Dz = [1,2,-5;3,1,4;-3,4,-7].

Next, I will solve for the determinant of each matrix. To do this, I can manually solve the determinant of each matrix on paper using the formula provided above. It can be tedious, but it’s okay since good math skills are developed by doing lots of problems.

The values of the determinants are listed below.

Determinants of each matrix:

The determinant of coefficient matrix D is equal to 40 which is written as |D|=40. The determinant of x-matrix D is equal to -40, therefore, |Dx|=-40. Also, y-matrix D has a determinant value of 40 and so |Dy|=40. Finally, the determinant of z-matrix D has the value of -80 which can be expressed as |Dz|=-80.

The final answers or solutions are easily computed or calculated once all the required determinants are found.

Solved values for [latex]\large{\color{green}x}[/latex], [latex]\large{\color{green}y}[/latex], and [latex]\large{\color{green}z}[/latex].

To solve for x, x = |Dx| divided by |D| = -40/40 = -1; to find the value of y we have y = |Dy| divided by |D| = 40/40 = 1; and finally to solve for z value we have z = |Dz| divided by |D| = -80/40 = -2. That means x=-1, y=1 and z=-2.

The final answer written in point notation is [latex]\color{blue}\left( {x,y,z} \right) = \left( { – 1,1, – 2} \right)[/latex].


Example 2: Solve the system with three variables by Cramer’s Rule.

The system of linear equations with three (3) variables x, y, and z are -2x-y-3z=3, 2x-3y+z=-13, and 2x-3z=-11

I actually consider the coefficient matrix as the “primary” matrix because the other three matrices are derived from it. For instance, the [latex]x-[/latex]matrix is just the “primary” matrix with the [latex]x-[/latex]column replaced by the constant column (in red). You can observe that the same pattern is applied in constructing the other matrices: [latex]y[/latex] and [latex]z[/latex].

  • coefficient matrix
Coefficient matrix D has elements -2, -1 and -3 on its first row; elements 2, -3 and 1 on its second row; elements 2, 0 and -3 on its third row. This can be expressed as D = [-2,-1,-3;2,-3,1;2,0,-3].
  • X – matrix
X-matrix D or Dx has elements 3, -1 and -3 on its first row; elements -13, -3 and 1 on its second row; elements -11, 0 and -3 on its third row. This can be expressed as Dx = [3,-1,-3;-13,-3,1;-11,0,-3].
  • Y – matrix
Y-matrix D or Dy has elements -2, 3 and -3 on its first row; elements 2, -13 and 1 on its second row; elements 2, -11 and -3 on its third row. This can be expressed as Dy = [-2,3,-3;2,-13,1;2,-11,-3].
  • Z – matrix
Z-matrix D or Dz has elements -2, -1 and 3 on its first row; elements 2, -3 and -13 on its second row; elements 2, 0 and -11 on its third row. This can be expressed as D = [-2,-1,3;2,-3,-13;2,0,-11].

After solving the determinant of each matrix, I have them all written down.

Determinants of each matrix:

The coefficient matrix D has a determinant value of -44 or |D|=-44. While, x-matrix D has a determinant value of 176 or |Dx|=176. In addition, y-matrix D has a determinant of -88 or |Dy|=-88. And finally, z-matrix D has a determinant of -44 or |Dz|=-44.

The values for [latex]x[/latex], [latex]y[/latex] and [latex]z[/latex] are calculated as follows. Notice that [latex]x[/latex] is obtained by taking the determinant of the [latex]x-[/latex]matrix divided by the determinant of the coefficient matrix. This rule holds for the rest.

Solved values for [latex]\large{\color{green}x}[/latex], [latex]\large{\color{green}y}[/latex], and [latex]\large{\color{green}z}[/latex].

Now solving for the values of x, y, and z, we have the following steps. For x, we show that x = |Dx| divided by |D| = 176/-44 = -4 therefore x = -4. For y, we show that y = |Dy| divided by |D| = -88/-44 = 2 therefore y = 2. Finally for z, we show that z = |Dz| divided by |D| = -44/-44 = 1 therefore z = 1.

Our final answer is [latex]\color{blue}\left( {x,y,z} \right) = \left( { – \,4,2,1} \right)[/latex].


Example 3: Solve the system with three variables by Cramer’s Rule.

the system of linear equations with three variables to be solved in this example contains the following equations: -y-2z=-8, x+3z=2 and 7x+y+z=0

This problem is much easier than the first two examples because of the presence of zero entries in the [latex]x[/latex], [latex]y[/latex], and constant columns. Do you see it? When we have zero entries in a matrix, the calculation of its determination is dramatically simplified.

In fact, as you increase the number of zeroes in a square matrix, the work done to find its determinant is greatly reduced.

Here are the matrices extracted from the system of linear equations.

  • coefficient matrix
Coefficient matrix D can be written in compact form as D = [0,-1,-2;1,0,3;7,1,1] which means that the first row has the elements 0, -1 and -2, the second row has elements 1, 0, and 3, and finally the third row has elements 7, 1 and 1.
  • X – matrix
X-matrix D can be written in compact form as Dx = [-8,-1,-2;2,0,3;0,1,1] which means that the first row has the elements -8, -1 and -2, the second row has elements 2, 0, and 3, and finally the third row has elements 0, 1 and 1.
  • Y – matrix
Y-matrix D can be written in compact form as Dy = [0,-8,-2;1,2,3;7,0,1] which means that the first row has the elements 0, -8 and -2, the second row has elements 1, 2, and 3, and finally the third row has elements 7, 0 and 1.
  • Z – matrix
Z-matrix D can be written in compact form as Dz = [0,-1,-8;1,0,2;7,1,0] which means that the first row has the elements 0, -1 and -8, the second row has elements 1, 0, and 2, and finally the third row has elements 7, 1 and 0.

Solving for their determinants, I got the following values.

Determinants of each matrix:

These are the values of the four determinants that we calculated above, namely, for coefficient matrix D, x-matrix D, y-matrix D and z-matrix D which give us |D|=-22, |Dx|=22, |Dy|=-132 and |Dz|=-22.

This leads us to easily set up and calculate the final answers.

Solved values for [latex]\large{\color{green}x}[/latex], [latex]\large{\color{green}y}[/latex], and [latex]\large{\color{green}z}[/latex].

Now to compute the solutions, that means to find the values of x, y and z, we have the following setup. To solve for x, x is equal to the determinant of the X-matrix D divided by the determinant coefficient matrix D which gives us x = |Dx|/|D| = 22/-22 = -1. Additionally, to solve for y, y is equal to the determinant of the Y-matrix D divided by the determinant of coefficient matrix D which gives us y = |Dy|/|D| = -132/-22 = 6. Lastly, to solve for z, z is equal to the determinant of the Z-matrix D divided by the determinant of coefficient matrix D which gives us z = |Dz|/|D| = -22/-22 = 1. Therefore, x=-1, y=6 and z=1.

The final answer is [latex]\color{blue}\left( {x,y,z} \right) = \left( { – \,1,6,1} \right)[/latex].


Example 4: Solve the system with three variables by Cramer’s Rule

In this example, we will solve the following system of linear equations with three (3) variables using the Cramer's Rule method. The first linear equation is -2x+y+z=4, the second linear equation is -4x+2y-z=8, and finally, the third linear equation is -6x-3y+z=0.

Write down the four special matrices.

  • coefficient matrix
The coefficient matrix D in math or symbolic form is D = [-2, 1, 1; -4, 2, -1; -6, -3, 1].
  • X – matrix
The X-matrix D in math or symbolic form is Dx = [4, 1, 1; 8, 2, -1; 0, -3, 1].
  • Y – matrix
The Y-matrix D in math or symbolic form is Dy = [-2, 4, 1; -4, 8, -1; -6, 0, 1].
  • Z – matrix
The Z-matrix D in math or symbolic form is Dz = [-2, 1, 4; -4, 2, 8; -6, -3, 0].

Evaluate each matrix to find its determinant.

These are the determinants of each matrix:

The determinant of coefficient matrix D is equal to 36. The determinant of X-matrix is equal to -36. While the determinant of Y-matrix D is equal to 72. Lastly, the determinant of Z-matrix D is equal to 0. The values of the four (4) determinants in math or symbolic form are as follows: |D|=36, |Dx|=-36, |Dy|=72 and |Dz|=0.

Use the Cramer’s Rule to get the following solutions.

Solved values for [latex]\large{\color{green}x}[/latex], [latex]\large{\color{green}y}[/latex], and [latex]\large{\color{green}z}[/latex].

After solving the values of four determinants, we then find the solutions to the given system of linear equations by the following steps: for x, we have x = |Dx|/|D| = -36/36= -1; for y, we have y = |Dy|/|D| = 72/36= 2 ; for z, we have z = |Dz|/|D| = 0/36 = 0. Therefore, x=-1, y = 2 and z = 0.

The final answer is [latex]\color{blue}\left( {x,y,z} \right) = \left( { – \,1,2,0} \right)[/latex].


Example 5: Solve the system with three variables by Cramer’s Rule

Here is the system of linear equations with three variables to solve: {x-8y+z=4, -x+2y+z=2, z-y+2z=-1}.

Let’s do one final example! I hope that at this point, you have had enough practice on how to solve systems with three variables using Cramer’s Rule.

I suggest that you solve this on paper first and then come back to compare your answer. When you are ready, scroll down to see the solution.

green arrow pointing down

Construct the four special matrices.

  • coefficient matrix
The first matrix is called the coefficient matrix D where the first row contains the entries of 1, -8 and 1; and the second row contains the entries of -1, 2 and 1; and the third row contains the elements of 1, -1 and 2. We can write this coefficient matrix D in condense or compact for as D = [1, -8, 1; -1, 2, 1; 1, -1, 2].
  • X – matrix
The second matrix is called the X- matrix D where the first row contains the entries of 4, -8 and 1; and the second row contains the entries of 2, 2 and 1; and the third row contains the elements of -1, -1 and 2. We can write this X-matrix D in condense or compact for as Dx = [4, -8, 1; 2, 2, 1; -1, -1, 2].
  • Y – matrix
The third matrix is called the Y-matrix D where the first row contains the elements of 1, 4 and 1; and the second row contains the elements of -1, 2 and 1; and the third row contains the elements of 1, -1 and 2. We can write this Y-matrix D in condense or compact for as Dy = [1, 4, 1; -1, 2, 1; 1, -1, 2].
  • Z – matrix
The fourth matrix is called the Z-matrix D where the first row contains the elements of 1, -8 and 4; and the second row contains the entries of -1, 2 and 2; and the third row contains the entries of 1, -1 and -1. We can write this Z-matrix D in condense or compact for as Dy = [1, -8, 4; -1, 2, 2; 1, -1, -1].

Find the determinant of each square matrix.

Determinants of each matrix

These are the numerical values of the determinants of the four matrices namely coefficient matrix, x-matrix, y-matrix, and z-matrix. For the coefficient matrix, the determinant is |D|=-20. For the x-matrix, the determinant is |Dx| = 60. For the y-matrix, the determinant is |Dy|=16. And finally, the determinant of z-matrix is |Dz|=-12.

Solve for [latex]x[/latex], [latex]y[/latex] and [latex]z[/latex] using the given formula.

Solved values for [latex]\large{\color{green}x}[/latex], [latex]\large{\color{green}y}[/latex], and [latex]\large{\color{green}z}[/latex].

To find the solution of the system of linear equations using Cramer's Rule with 3 Variables involves finding the values of x, y, and z which corresponds to the point (x,y,z). So, for x = |Dx|/|D| = 60/-20 = -3; for y = |Dy|/|D| = 16/-20 = -4/5; and lastly, for z= |Dz|/|D| = -12/-20 = 3/5. The key is to divide the determinant of x-matrix, y-matrix, or z-matrix by the determinant of the coefficient depending on what you want to find.

Done! The final answer in point form is [latex]\color{blue}\left( {x,y,z} \right) = {\large{\left( { – \,3, – {4 \over 5},{3 \over 5}} \right)}}[/latex].


You may also be interested in these related math lessons or tutorials:

Cramer’s Rule 2×2

Determinant of a 2×2 Matrix

Determinant of a 3×3 Matrix