W3 Lesson 3 - Systems of Linear Equation - Module
W3 Lesson 3 - Systems of Linear Equation - Module
1
Systems of Linear Equation
Cramer’s Rule
The knowledge in finding the determinants is essential in Cramer’s Rule. Recall for a
system of linear equations given below,
𝐸𝑞 1
Course Module
Where the blue arrow and the red arrow signifies the sign of the product of the
elements that is, positive and negative respectively.
Cramer’s rule provides a solution to systems of linear equations using the coefficient
matrix and of matrices obtained from it by replacing one column by the vector of
right hand sides of the equations.
Cramer’s rule can only be applied for square matrices obtained from
coefficient matrix since it uses determinants. The determinant should also be
non-zero because the value would be indeterminate.
Example
𝑥 + 2𝑦 +𝑧 =4
2𝑥 −𝑦 −𝑧 = 2
−𝑥 + 2𝑦 + 2𝑧 = 3
Procedure
1. Let D be the determinant of the coefficient matrix. In this example, the coefficient
matrix is given as
1 2 1
D = | 2 −1 −1|
−1 2 2
−1 −1 2 −1 2 −1
D =1 | | - 2| |+ 1| |
2 2 −1 2 −1 2
D = 1 (-2+2) - 2 (4-1)) +1(4-1)
2. In Cramer’s Rule, there is no need to go over entire matrix to get the value of one
variable. The next step involved is to replace the column of the vector of the
variable, let’s say column 1 for x, with the column vector of the constant terms.
This will be used to find the determinant, Dx
The column vector of the constant terms is given as
4
column vector of the constant [2]
3
Numerical Methods
3
Systems of Linear Equation
4 2 1
Dx = |2 −1 −1|
3 2 2
This is the ease of Cramer’s Rule. If you are only concerned with one variable, it
may be possible without using all the other variables at this final point.
In order to find the value of y and z, perform the second step but this time,
replacing Columns 2 and 3 with the column vector of the constant terms. That
will give us:
1 4 1
Dy = | 2 2 −1|
−1 3 2
And
1 2 4
Dz= | 2 −1 2|
−1 2 3
Dz = 1 ((-3)-4) - 2 (6+2)) +4(4-1)
−11 11
Dz = -11 therefore z = =
−3 3
The solution for the systems of linear equation using Cramer’s Rule is
7 11
x = 3 , y = -1 and z = 3
Course Module
Cramer’s rule
1. Create a coefficient matrix for the systems of linear equation.
2. Use the coefficient matrix to solve for the determinant.
3. Create a column vector from the right hand side of the equation
4. Replace the column of the coefficient of the variable to be solved.
5. Perform the operation in finding the determinant for that particular
variable
6. Get the ratio of the determinant obtained by replacing the column of the
variable with the column of the constant terms and the determinant of
the coefficient matrix. (e.g. Dx/D)
Gaussian Elimination
Gaussian Elimination method is the standard method for solving the linear
system by using a calculator or a computer. It transforms a linear system into
an upper triangular form, which is easier to solve.
Unlike the Cramer’s rule, the Gaussian method can work even in non-square
matrices thus it making it more useful in finding the solution for systems of
linear equation.
Using the same given, the procedure for the Gaussian Elimination is
described by the example below:
𝑥 + 2𝑦 +𝑧 =4
2𝑥 −𝑦 −𝑧 = 2
−𝑥 + 2𝑦 + 2𝑧 = 3
Procedure
1. In the first step of the elimination procedure, find the pivot in the 1st column in
the 1st row.
2. The goal is to transform the linear system into an upper triangular form (also
known as the row echelon form)
So using the first row (R1) to eliminate the x term in second row (R2), R1 must be
multiplied to 2 first
2𝑥 + 4𝑦 + 2𝑧 = 8
2𝑥 −𝑦 −𝑧 = 2
−𝑥 + 2𝑦 + 2𝑧 = 3
then subtract to R2 and the rest to modify R2 and the rest, just restore it.
𝑥 + 2𝑦 +𝑧 =4
0 −5𝑦 −3𝑧 = −6
−𝑥 + 2𝑦 + 2𝑧 = 3
3. The x term at the third row should be eliminated. To do that, using the pivot,
multiply R1 by -1.
−𝑥 − 2𝑦 − 𝑧 = −4
0 +5𝑦 +3𝑧 = +6
−𝑥 + 2𝑦 + 2𝑧 = 3
then subtract to R3 and the rest to modify R3 and the rest, just restore it.
𝑥 + 2𝑦 +𝑧 = 4
0 −5𝑦 −3𝑧 = −6
0 + 4𝑦 +3𝑧 = +7
4. Make the pivot in the 2nd column by dividing the 2nd row by -5
𝑥 + 2𝑦 +𝑧 = 4
3
0 +𝑦 − 𝑧 = −6/5
5
0 + 4𝑦 +3𝑧 = 7
The value of the pivot should be non-zero. If the coefficient of the first
variable is zero, try rearranging the systems of linear equations first. If
possible, try to put the zero values to produce the upper triangular form
without violating the orders of the variables which should all be aligned all
throughout the computations.
Course Module
𝑥 + 2𝑦 +𝑧 = 4
12
0 + 4𝑦 − 𝑧 = −24/5
5
0 + 4𝑦 +3𝑧 = 7
then subtract to R3 and the rest to modify R3 and the rest, just restore it.
𝑥 + 2𝑦 +𝑧 = 4
12 −24
0 + 4𝑦 − 𝑧= 5
5
0 +0 −3𝑧 = −11
This completes the first phase also called as the forward elimination of Gaussian
elimination method. The second phase which is the back substitution involves,
getting the value of the variable from the bottom of the systems of linear
11
equation. This will give, z = 3 . Substituting it backwards to the second equation
7
will give y = -1 and x =3
The solution for the systems of linear equation using Gaussian elimination
method is
7 11
x = 3 , y = -1 and z = 3
For the Gaussian elimination method, there are two processes involved the
forward elimination and the back substitution. There is no particular order of
operations in using this method as long as the upper triangular form is
correctly obtained.
Gauss-Jordan Elimination
0 1 0 = 𝑏2
0 0 1 = 𝑏3
𝑥 + 2𝑦 +𝑧 =4
2𝑥 −𝑦 −𝑧 = 2
−𝑥 + 2𝑦 + 2𝑧 = 3
1 2 1 4
2 −1 −1 2
[−1 2 2 3]
2. Normalize the coefficients of the first row. The first element should be 1,
meaning the coefficient of the first linear equation should be non-zero.
Suppose the coefficient of the pivot is 3, then to normalize the first row
means, first row (R1) should be divided by 3. But in the example that we
have, the coefficient is already 1.
2 −1 −1 2
[−1 2 2 3]
b. Subtract R1 from row 2 (R2) and restore it
1 2 1 4
0 −5 −3 −6
[−1 2 2 3]
Course Module
c. Multiply the R1 by -1
−1 −2 −1 −4
0 −5 −3 −6
[−1 2 2 3]
1 2 1 4
0 −5 −3 −6
[0 4 3 7]
1 2 1 4
3 6
0 1
5 5
[0 4 3 7]
When trying to get the value of the bottom part of the systems of
linear equation Gaussian elimination method, notice the pivot was
moved to second row second column. The forward elimination should
be done such that, when subtracting rows, the previously eliminated
part should not be affected.
f. Multiply the R2 by 2
1 2 1 4
6 12
0 2
5 5
[0 4 3 7]
−1 8
1 0
5 5
3 6
0 1
5 5
[0 4 3 7]
h. Multiply the R2 by 4
Numerical Methods
9
Systems of Linear Equation
−1 8
1 0
5 5
12 24
0 4
5 5
[0 4 3 7]
−1 8
1 0
5 5
3 6
0 1
5 5
3 11
[0 0
5 5]
−1 8
1 0
5 5
3 6
0 1
5 5
11
[0 0 1
3]
−1 8
1 0
5 5
3 6
0 1
5 5
−1 −11
[0 0
5 15 ]
Course Module
7
1 0 0
3
3 6
0 1
5 5
11
[0 0 1
3]
3 6
0 1
5 5
3 11
[0 0
5 5]
7
1 0 0
3
0 1 0 −1
11
[0 0 1
3]
The solution using Gauss-Jordan method for the system of linear equations
𝑥 + 2𝑦 +𝑧 =4
2𝑥 −𝑦 −𝑧 = 2
−𝑥 + 2𝑦 + 2𝑧 = 3
Is x = 7/3; y = -1 and z = 11/3.
Numerical Methods
11
Systems of Linear Equation
Chapra, Steven C.; Applied numerical methods with MATLAB for engineers and scientists.
Steven C. Chapra. McGraw-Hill; 3rd ed.
Chapra, Steven C.; Numerical methods for engineers . Steven C. Chapra, Raymond P.
Canale. McGraw-Hill; 6th ed
Cheney, E Ward (2013). Numerical Mathematics and Computing Cengage Learning; 7th
ed.
Course Module