Skip to content

EXAMPLE B.7 Using Cramer's Rule to Solve a System of Equations

← Back to LINEAR SYSTEMS AND SIGNALS Overview

EXAMPLE B.7 Using Cramer’s Rule to Solve a System of Equations

Use Cramer’s rule to solve the following simultaneous linear equations in three unknowns:

2x1+x2+x3=32x_1 + x_2 + x_3 = 3 x1+3x2βˆ’x3=7x_1 + 3x_2 - x_3 = 7 x1+x2+x3=1x_1 + x_2 + x_3 = 1

In matrix form, these equations can be expressed as

⎑
2
1⎀
1
⎑
x1
⎀⎑
⎀
3
1
⎣
3βˆ’1
⎦
x2
⎣
⎦ =7
⎣
⎦
111x31

Here,

∣A∣=∣21113βˆ’1111∣=4|\mathbf{A}| = \begin{vmatrix} 2 & 1 & 1 \\ 1 & 3 & -1 \\ 1 & 1 & 1 \end{vmatrix} = 4

Since |A| = 4 = 0, a unique solution exists for x1, x2, and x3. This solution is provided by Cramer’s rule [Eq. (B.21)] as follows:

x1=1∣A∣∣31173βˆ’1111∣=84=2x_1 = \frac{1}{|\mathbf{A}|} \begin{vmatrix} 3 & 1 & 1 \\ 7 & 3 & -1 \\ 1 & 1 & 1 \end{vmatrix} = \frac{8}{4} = 2 x2=1∣A∣∣23117βˆ’1111∣=44=1x_2 = \frac{1}{|\mathbf{A}|} \begin{vmatrix} 2 & 3 & 1 \\ 1 & 7 & -1 \\ 1 & 1 & 1 \end{vmatrix} = \frac{4}{4} = 1 x3=1∣A∣∣213137111∣=βˆ’84=βˆ’2x_3 = \frac{1}{|\mathbf{A}|} \begin{vmatrix} 2 & 1 & 3 \\ 1 & 3 & 7 \\ 1 & 1 & 1 \end{vmatrix} = \frac{-8}{4} = -2

MATLAB is well suited to compute Cramer’s formula, so these results are easy to verify. To provide an example, let us verify that x1 = 2 using MATLAB’s det command to compute the needed matrix determinants.

>> x1 = det([3 1 1;7 3 -1;1 1 1])/det([2 1 1;1 3 -1;1 1 1])
x1 = 2.0000