Cramer's Rule with Questions and Solutions

Cramer's rule are used to solve a systems of n linear equations with n variables using explicit formulas. We first start with a proof of Cramer's rule to solve a 2 by 2 systems of linear equations. Rules for 3 by 3 systems of equations are also presented. Then examples and questions with detailed solutions are presented.
To check answers when solving 2 by 2 and 3 by 3 systems of equations, you may want to use these online Systems of Equations Calculator and Solver.

Cramer's Rules for a 2 by 2 System of Equations

To find rules (or formulas) that may be used solve any 2 by 2 system of linear equations, we need to solve the general system of the form
general 2 by 2 systems of linear equations

We multiply equation (1) by b
2 and equation (2) by - b 1.
\( \left\{ \begin{array}{lcl} a_1 b_ 2 x + b_1 b_2 y & = & c_1 b_2\\ -a_2 b_1 x - b_2 b_1 y & = & - c_2 b_1 \end{array} \right. \)

Add the left sides and the right sides of the above equations and simplify to obtain an equation in one variable.
\( a_1 b_2 x - a_2 b_1 x = c_1 b_2 - c_2 b_1 \)

Factor x out on the left side
\( x(a_1 b_2 - a_2 b_1) = b_2 c_1 - b_1 c_2 \)

Solve the above equation for x
\( x = \dfrac{c_1 b_2 - c_2 b_1}{a_1 b_2 - a_2 b_1} \)

We may use similar steps to eliminate x and solve for y to obtain.
\( y = \dfrac{a_1 c_2 - a_2 c_1}{a_1 b_2 - a_2 b_1} \)

The solution to the given 2 by 2 system of linear equations is given by Cramer's rules as follows
\[ x = \dfrac{D_x}{D} , y = \dfrac{D_y}{D} \]
Using the
determinant of a 2 by 2 Matrix notation, \( D \), \( D_x \) and \( D_y \) are defined by

\( D = \begin{vmatrix}a_1&b_1\\ a_2&b_2\end{vmatrix} = a_1 b_2 - b_1 a_2\)

\( D_x = \begin{vmatrix}\color{red}{c_1} & b_1\\ \color{red}{c_2} & b_2\end{vmatrix} = c_1 b_2 - b_1 c_2\)

\( D_y = \begin{vmatrix}a_1 & \color{red}{c_1}\\ a_2 & \color{red}{c_2}\end{vmatrix} = a_1 c_2 - c_1 a_2\)

  • Example 1
    Use Cramer's rule to solve the system \[ \left\{ \begin{array}{lcl} 2 x - 3 y & = & 5 \\ -4 x + 7 y & = & -11 \end{array} \right. \] Solution to Example 1
    Calculate the determinants \( D, D_x \text{and} D_y \)
    \( D = \begin{vmatrix}2 & -3\\ -4 & 7\end{vmatrix} = (2)(7) - (-3)(-4) = 2 \)

    \( D_x = \begin{vmatrix} 5 & -3\\ -11 & 7\end{vmatrix} = (5)(7) - (-3)(-11) = 2 \)

    \( D_y = \begin{vmatrix} 2 & 5\\ -4 & -11\end{vmatrix} = (2)(-11) - (5)(-4) = -2 \)

    We now use Cramer's rule to calculate the unknowns \(x\) and \(y\).
    \( x = \dfrac{D_x}{D} = \dfrac{2}{2} = 1 \)

    \( y = \dfrac{D_y}{D} = \dfrac{-2}{2} = -1 \)

    As an exercise, substitute \(x\) and \(y\) by 1 and -1 respectively in the given system and check that the solution found satisfies the system of equation.
    Note: If the determinant D is equal to zero, Cramer's rule cannot be used to solve a system of linear equations.

Cramer's Rules for a 3 by 3 System of Equations

A general 3 by 3 systems of linear equations may be written as follows: \[ \left\{ \begin{array}{lcl} a_1 x + b_1 y + c_1 z = & \color{red}{d_1} & (1)\\ a_2 x + b_2 y + c_2 = & \color{red}{d_2} & (2) \\ a_3 x + b_3 y + c_3 = & \color{red}{d_3} & (2) \\ \end{array} \right. \]

For a 3 by 3 system of linear equations, Cramer's rule gives the solution as follows
\[ x = \dfrac{D_x}{D} , y = \dfrac{D_y}{D} , z = \dfrac{D_z}{D} \]
where \( D, D_x, D_y \text{and} D_z \) are determinants of 3 by 3 matrices defined by

\( D = \begin{vmatrix}a_1&b_1&c_1\\ a_2&b_2&c_2\\a_3 & b_3 & c_3 \end{vmatrix}\)

\( D_x = \begin{vmatrix}\color{red}{d_1} & b_1 & c_1\\ \color{red}{d_2} & b_2 & c_2 \\ \color{red}{d_3} &b_3&c_3 \end{vmatrix} \), \( D_y = \begin{vmatrix}a_1&\color{red}{d_1}&c_1\\ a_2&\color{red}{d_2}&c_2\\a_3 & \color{red}{d_3} & c_3 \end{vmatrix}\) , \( D_z = \begin{vmatrix}a_1&b_1&\color{red}{d_1}\\ a_2&b_2&\color{red}{d_2}\\a_3 & b_3 & \color{red}{d_3} \end{vmatrix}\)

  • Example 2
    Use Cramer's rule to solve the system \[ \left\{ \begin{array}{lcl} - x - 3 y - z & = & 6 \\ 2 x - 5 y - 2 z & = & 14 \\ x + y & = & -1 \end{array} \right. \] Solution to Example 2
    Calculate the determinants \( D, D_x ,D_y \text{and} D_z \)
    \( D = \begin{vmatrix} -1 & - 3 & -1 \\ 2 & -5 & -2\\ 1&1&0\end{vmatrix} = -1\cdot \begin{vmatrix}-5&-2\\ 1&0\end{vmatrix}-\left(-3\right) \begin{vmatrix}2&-2\\ 1&0\end{vmatrix}-1\cdot \begin{vmatrix}2&-5\\ 1&1\end{vmatrix} = -3\)

    \( D_x = \begin{vmatrix} 6 & - 3 & -1 \\ 14 & -5 & -2\\ -1&1&0\end{vmatrix} = 6\cdot \begin{vmatrix}-5&-2\\ 1&0\end{vmatrix}-\left(-3\right)\begin{vmatrix}14&-2\\ -1&0\end{vmatrix}-1\cdot \begin{vmatrix}14&-5\\ -1&1\end{vmatrix} = -3\)

    \( D_y = \begin{vmatrix} -1 & 6 & -1 \\ 2 & 14 & -2\\ 1& -1&0\end{vmatrix} = -1\cdot \begin{vmatrix}14&-2\\ -1&0\end{vmatrix}-6\cdot \begin{vmatrix}2&-2\\ 1&0\end{vmatrix}-1\cdot \begin{vmatrix}2&14\\ 1&-1\end{vmatrix} = 6\)

    \( D_z = \begin{vmatrix} -1 & - 3 & 6 \\ 2 & -5 & 14\\ 1&1&-1\end{vmatrix} = -1\cdot \begin{vmatrix}-5&14\\ 1&-1\end{vmatrix}-\left(-3\right) \begin{vmatrix}2&14\\ 1&-1\end{vmatrix}+6\cdot \begin{vmatrix}2&-5\\ 1&1\end{vmatrix} = 3\)
    Use Cramer's rule to calculate the unknowns \(x\), \(y\) and \(z\).
    \( x = \dfrac{D_x}{D} = \dfrac{-3}{-3} = 1 \)

    \( y = \dfrac{D_y}{D} = \dfrac{6}{-3} = -2 \)

    \( z = \dfrac{D_z}{D} = \dfrac{3}{-3} = -1 \)
    As an exercise, substitute \(x\), \(y\) and \(y\) by 1, -2 and 1 respectively in the given system to check the solution found.

Questions with Solution

  • Part 1
    Use Cramer's rule to solve the following systems of linear equations.
    a) \( \left\{ \begin{array}{lcl} 5 x - \dfrac{2}{3} y & = & \dfrac{1}{3} \\ - x + \dfrac{1}{2} y & = & - \dfrac{1}{2} \end{array} \right. \)     b) \( \left\{ \begin{array}{lcl} 0.1 x - 0.3 y & = & 1.1 \\ - 0.2 x + 1.3 y & = & - 1.5 \end{array} \right. \)

    c) \( \left\{ \begin{array}{lcl} - 3x + 5 y - z & = & \dfrac{1}{2} \\ \dfrac{1}{5} x - 5 y - \dfrac{3}{5} z & = & 0 \\ -4 x + \dfrac{4}{5} y - z & = & - 7 \end{array} \right. \)

  • Part 2
    Use Cramer's rule to find the solution of the systems of linear equations in terms of the parameter k.
    a) \( \left\{ \begin{array}{lcl} 5 x - k y & = & 6 \\ - 2 x + 2 k y & = & - 3 \end{array} \right. \)     b) \( \left\{ \begin{array}{lcl} 2 x - 3 y & = & k \\ x + 2 y & = & -2k \end{array} \right. \)

  • Part 3
    Use Cramer's rule to find the solution of the systems of linear equations in terms of the parameters p and q.
    a) \( \left\{ \begin{array}{lcl} - x - 3 y & = & 5 p \\ - 2 x - 5 y & = & - 2 q \end{array} \right. \)

    b) Use your answer to a) to solve the systems
    1) \( \left\{ \begin{array}{lcl} - x - 3 y & = & 10 \\ - 2 x - 5 y & = & - 4 \end{array} \right. \)     2) \( \left\{ \begin{array}{lcl} - x - 3 y & = & 5/2 \\ - 2 x - 5 y & = & - 2 \end{array} \right. \)     3) \( \left\{ \begin{array}{lcl} - x - 3 y & = & 50 \\ - 2 x - 5 y & = & 6 \end{array} \right. \)

  • Part 4
    Solve the system and show that the solution does not depends on the parameter p.
    \( \left\{ \begin{array}{lcl} 5 x - 6 y + 6 z & = & -14 \\ 9 x - p y - z & = & 22 \\ -2 x - 6 y & = & -4 \end{array} \right. \)

Solutions to the Above Questions

  • Part 1
    a) Calculate the determinants
    \( D = \begin{vmatrix} 5 & -2/3\\ -1 & 1/2 \end{vmatrix} = (5)(1/2)-(-2/3)(-1) = 11/6\)

    \( D_x = \begin{vmatrix} 1/3 & -2/3\\ -1/2 & 1/2 \end{vmatrix} = (1/3)(1/2)-(-2/3)(-1/2) = -1/6\)

    \( D_y = \begin{vmatrix} 5 & 1/3\\ -1 & -1/2 \end{vmatrix} = (5)(-1/2)-(1/3)(-1) = -13/6\)

    The solution is given by Cramer's rule as follows
    \( x = \dfrac{D_x}{D} = -\dfrac{1}{11} \)

    \( y = \dfrac{D_y}{D} = -\dfrac{13}{11} \)

    b) The determinants are given by
    \( D = \begin{vmatrix} 0.1 & -0.3\\ -0.2 & 1.3 \end{vmatrix} = (0.1)(1.3) - (-0.3)(-0.2) = 0.07\)

    \( D_x = \begin{vmatrix} 1.1 & -0.3\\ -1.5 & 1.3 \end{vmatrix} = (1.1)(1.3) - (-0.3)(-1.5) = 0.98\)

    \( D_y = \begin{vmatrix} 0.1 & 1.1\\ -0.2 & -1.5 \end{vmatrix} = (0.1)(-1.5) - (1.1)(-0.2) = 0.07\)

    The solution is given by
    \( x = \dfrac{D_x}{D} = \dfrac{0.98}{0.07} = 14 \)

    \( y = \dfrac{D_y}{D} = \dfrac{0.07}{0.07} = 1\)

    c) The 3 by 3 determinants \( D, D_x ,D_y \text{and} D_z \) are calculated using 2 by 2 determinants as follows
    \( D = \begin{vmatrix} -3 & 5 & -1 \\ 1/5 & -5 & - 3/5\\ -4 & 4/5 & -1 \end{vmatrix} = -3\cdot \begin{vmatrix}-5&-\frac{3}{5}\\ \frac{4}{5}&-1\end{vmatrix}-5\cdot \begin{vmatrix}\frac{1}{5}&-\frac{3}{5}\\ -4&-1\end{vmatrix}-1\cdot \begin{vmatrix}\frac{1}{5}&-5\\ -4&\frac{4}{5}\end{vmatrix} = 82/5 \)

    \( D_x = \begin{vmatrix} 1/2 & 5 & -1 \\ 0 & -5 & - 3/5\\ -7 & 4/5 & -1 \end{vmatrix} = \frac{1}{2} \begin{vmatrix}-5&-\frac{3}{5}\\ \frac{4}{5}&-1\end{vmatrix}-5\cdot \begin{vmatrix}0&-\frac{3}{5}\\ -7&-1\end{vmatrix}-1\cdot \begin{vmatrix}0&-5\\ -7&\frac{4}{5}\end{vmatrix} = 2937/50\)

    \( D_y = \begin{vmatrix} -3 & 1/2 & -1 \\ 1/5 & 0 & - 3/5\\ -4 & -7 & -1 \end{vmatrix} = -3\cdot \begin{vmatrix}0&-\frac{3}{5}\\ -7&-1\end{vmatrix}-\frac{1}{2} \begin{vmatrix}\frac{1}{5}&-\frac{3}{5}\\ -4&-1\end{vmatrix}-1\cdot \begin{vmatrix}\frac{1}{5}&0\\ -4&-7\end{vmatrix} = 153/10\)

    \( D_z = \begin{vmatrix} -3 & 5 & 1/2 \\ 1/5 & -5 & 0\\ -4 & 4/5 & - 7 \end{vmatrix} = -3\cdot \begin{vmatrix}-5&0\\ \frac{4}{5}&-7\end{vmatrix}-5\cdot \begin{vmatrix}\frac{1}{5}&0\\ -4&-7\end{vmatrix}+\frac{1}{2} \begin{vmatrix}\frac{1}{5}&-5\\ -4&\frac{4}{5}\end{vmatrix} = -2698/25\)

    The solution is given by
    \( x = \dfrac{D_x}{D} = \dfrac{2937/50}{82/5} = \dfrac{2937}{820} \)

    \( y = \dfrac{D_y}{D} = \dfrac{153/10}{82/5} = \dfrac{153}{164} \)

    \( z = \dfrac{D_z}{D} = \dfrac{-2698/25}{82/5} = -\dfrac{1349}{205} \)


  • Part 2
    a) The determinants are given by
    \( D = \begin{vmatrix} 5 & -k\\ -2 & 2k \end{vmatrix} = (5)(2k)-(-k)(-2) = 8 k \)

    \( D_x = \begin{vmatrix} 6 & -k\\ -3 & 2k \end{vmatrix} = (6)(2k)-(-k)(-3) = 9 k \)

    \( D_y = \begin{vmatrix} 5 & 6\\ -2 & -3\end{vmatrix} = (5)(-3)-(6)(-2) = - 3 \)

    Solution to the system
    \( x = \dfrac{D_x }{D} = \dfrac{9k}{8k} = \dfrac{9}{8} \)     ,     \( y = \dfrac{D_y }{D} = \dfrac{-3}{8k} = -\dfrac{3}{8k} \)

    b) The determinants are given by
    \( D = \begin{vmatrix} 2 & - 3\\ 1 & 2 \end{vmatrix} = (2)(2) - (-3)(1) = 7 \)

    \( D_x = \begin{vmatrix} k & - 3\\ -2 k & 2 \end{vmatrix} = (k)(2) - (-3)(-2k) = -4k \)

    \( D_y = \begin{vmatrix} 2 & k\\ 1 & -2k \end{vmatrix} = (2)(-2k) - (k)(1) = -5k \)
    Solution to the system
    \( x = \dfrac{D_x }{D} = \dfrac{-4k}{7} = -\dfrac{4}{7}k \)     ,     \( y = \dfrac{D_y }{D} = \dfrac{-5k}{7} = -\dfrac{5}{7}k \)


  • Part 3
    a) Using Cramer's rule, the solutions are given by
    \( x = 6 q + 25 p \)         \( y = -2 q - 10 p \)

    b)
    1) If we substitute the parameters p and q in the system of equations in a) by 2 and 2 respectively, we obtain the system of equation
    \( \left\{ \begin{array}{lcl} - x - 3 y & = & 10 \\ - 2 x - 5 y & = & - 4 \end{array} \right. \)
    that we have to solve. But the system in a) has been solved for all values of p and q. Hence to solve the system in b) 1), we substitute p and q by their values (2 and 2) in the solutions obtained in a) which gives.
    \( x = 6 q + 25 p = 6(2) + 25(2) = 62 \)         \( y = -2 q - 10 p = -2 (2) - 10 (2) = -24 \)

    2) For this system p = 1/2 and q = 1; hence the solution
    \( x = 6 q + 25 p = 6(1) + 25(1/2) = 37/2 \)         \( y = -2 q - 10 p = -2 (1) - 10 (1/2) = - 7 \)

    3) For this system p = 10 and q = -3; hence the solution
    \( x = 6 q + 25 p = 6(-3) + 25(10) = 232 \)         \( y = -2 q - 10 p = -2(-3) - 10(10) = - 94 \)

  • Part 4
    The determinants used in Cramer's rule are given by

    \( D = \begin{vmatrix}5&-6&6\\ \:\:9&-p&-1\\ \:\:-2&-6&0\end{vmatrix} =5\cdot \begin{vmatrix}-p&-1\\ -6&0\end{vmatrix}-\left(-6\right) \begin{vmatrix}9&-1\\ -2&0\end{vmatrix}+6\cdot \begin{vmatrix}9&-p\\ -2&-6\end{vmatrix} = -12p-366\)

    \( D_x = \begin{vmatrix}-14&-6&6\\ \:\:22&-p&-1\\ \:\:\:-4&-6&0\end{vmatrix} = -14\cdot \begin{vmatrix}-p&-1\\ -6&0\end{vmatrix}-\left(-6\right) \begin{vmatrix}22&-1\\ -4&0\end{vmatrix}+6\cdot \begin{vmatrix}22&-p\\ -4&-6\end{vmatrix} = -24p-732\)

    \( D_y = \begin{vmatrix}5&-14&6\\ \:\:\:9&22&-1\\ \:\:\:-2&-4&0\end{vmatrix} = =5\cdot \begin{vmatrix}22&-1\\ -4&0\end{vmatrix}-\left(-14\right) \begin{vmatrix}9&-1\\ -2&0\end{vmatrix}+6\cdot \begin{vmatrix}9&22\\ -2&-4\end{vmatrix} = 0 \)

    \( D_z = \begin{vmatrix}5&-6&-14\\ \:\:\:9&-p&22\\ \:\:\:-2&-6&-4\end{vmatrix} = =5\cdot \begin{vmatrix}-p&22\\ -6&-4\end{vmatrix}-\left(-6\right) \begin{vmatrix}9&22\\ -2&-4\end{vmatrix}-14\cdot \begin{vmatrix}9&-p\\ -2&-6\end{vmatrix} = 48p+1464\)

    The solutions are given by Cramer's rule as follows

    \( x = \dfrac{D_x}{D} = \dfrac{-24p-732}{-12p-366} = 2 \)

    \( y = \dfrac{D_y}{D} = \dfrac{0}{-12p-366} = 0 \)

    \( z = \dfrac{D_z}{D} = \dfrac{48p+1464}{-12p-366} = -4 \)

References and Links Related to Systems of Equations and Determinant

Gaussian Elimination to Solve Systems - Questions with Solutions. Gaussian Elimination Solver Calculator for a 3 by 3 Systems of Equations.
Solver Calculator to Solve 3 by 3 Systems of Equations Using Cramers' Rules.
Solve Systems of Equations - Tutorial. Method of elimination.
More on
Determinant of a Matrix and Cramer's rule.
Solve Systems of Equations - Tutorial.
Systems of Equations Calculator and Solver.

privacy policy