College of Engineering
NUMERICAL METHODS AND ANALYSIS -
LABORATORY
(GEN0130L)
LABORATORY EXERCISE NO. 4
Roots of Linear Function: Direct Methods
FINAL GRADE
Name of Student:
Date of Performance:
Date of Submission:
Name of Instructor:
Signature of Instructor:
NUMERICAL METHODS AND ANALYSIS – LABORATORY 1|P a g e
College of Engineering
LABORATORY EXERCISE NO. 4
Roots of Linear Function: Direct Methods
OBJECTIVES:
At the end of this laboratory exercise, the students are expected:
1. To demonstrate the characteristics of Direct Method in solving System of Linear Equations.
2. To be able to learn how to use Gauss-Elimination Method on Linear Functions.
3. To be able to learn how to use Gauss-Jordan Method on Linear Functions.
4. To be able to learn how to use Matrix Inverse Method on Linear Functions.
MATERIALS/EQUIPMENT REQUIRED:
Quantity Materials/Equipment
1 Computer (with MS Excel)
INTRODUCTION:
Direct methods compute the solution to a problem in a finite number of steps. These
methods would give the precise answer if they were performed in infinite precision arithmetic.
Examples include Gaussian elimination, the QR factorization method for solving systems of linear
equations, and the simplex method of linear programming. In practice, finite precision is used and
the result is an approximation of the true solution (assuming stability).
Direct techniques are methods that theoretically give the exact solution to the system in a
finite number of steps. In practice, of course, the solution obtained will be contaminated by the
round-off error that is involved with the arithmetic being used. Analyzing the effect of this round-
off error and determining ways to keep it under control will be a major component of this
presentation. Examples of Direct methods are Inverse Matrix, Gauss-Jordan, Gauss-Elimination and
LU (Lower and Upper) Decomposition.
NUMERICAL METHODS AND ANALYSIS – LABORATORY 2|P a g e
College of Engineering
DISCUSSION:
MATRIX INVERSE
• The inverse of a square matrix A, denoted by A-1, is a square matrix with the property
A-1A = AA-1 = I,
where I is an identity matrix of the same size.
• Useful properties of the inverse of a nonsingular matrix A:
(A−1)−1 = A
AA−1 = A−1A = I
AT is also nonsingular, and (AT )−1 =(A−1)T
This follows easily by taking the transpose of both sides of AA −1 = I.
If B is also nonsingular, then so is the product AB, and (AB)−1 = B−1A−1
LINEAR SYSTEM
• Given the output of a linear system for which the coefficient matrix A is known, is it possible
to determine its input? This would involve solving the equation
Ax = b
• Matrices provide a concise notation for representing and solving simultaneous linear
equations, for example:
a11 x1 a12 x 2 a13 x 3 b1 a11 a12 a13 x1 b1
a21 x1 a22 x 2 a23 x 3 b2 a21 a22 a23 x 2 b2
a33
a31 x1 a32 x 2 a33 x 3 b3 a31 a32 x 3 b3
[A]{x} {b}
NUMERICAL METHODS AND ANALYSIS – LABORATORY 3|P a g e
College of Engineering
GAUSS ELIMINATION
A sequential process of removing unknowns from equations using forward
elimination followed by back substitution is known as Gaussian elimination.
Forward elimination
Starting with the first row, add or subtract multiples of that row to eliminate the first
coefficient from the second row and beyond.
Continue this process with the second row to remove the second coefficient from the
third row and beyond.
Stop when an upper triangular matrix remains.
Backward substitution
Starting with the last row, solve for the unknown, then substitute that value into the
next highest row.
Because of the upper-triangular nature of the matrix, each row will contain only one
more unknown.
NUMERICAL METHODS AND ANALYSIS – LABORATORY 4|P a g e
College of Engineering
PIVOTING
Problems arise with naive Gauss elimination if a coefficient along the diagonal is 0
(problem: division by 0) or close to 0 (problem: round-off error)
One way to combat these issues is to determine the coefficient with the largest
absolute value in the column below the pivot element. The rows can then be
switched so that the largest element is the pivot element. This is called partial
pivoting.
If the rows to the right of the pivot element are also checked and columns switched,
this is called complete pivoting.
GAUSS JORDAN
Involves complete pivoting so that the coefficient matrix becomes diagonal
Eliminates the need for substitution
Also used in finding inverses
Steps
1. Write down the matrix corresponding to the linear system.
2. Make sure that the first entry in the first column is nonzero. Do this by interchanging
the first row with one of the rows below it, if necessary.
3. Pivot the matrix about the first entry in the first column.
Pivoting in this case also involves normalizing the diagonal entry
4. Make sure that the second entry in the second column is nonzero. Do this by
interchanging the second row with one of the rows below it, if necessary.
5. Pivot the matrix about the second entry in the second column.
6. Continue in this manner until you have the identity matrix on the left hand side.
NUMERICAL METHODS AND ANALYSIS – LABORATORY 5|P a g e
College of Engineering
PROCEDURES:
1. Turn on and log in to your computer terminals.
2. Click on MS Excel and prepare 3 excel worksheets for (a) Gauss Elimination Method, (b)
Gauss Jordan Method and (c) Matrix Inverse Method on the same file.
3. Rename the worksheets by right clicking the lower left hand tab flap “sheet 1” to “Gauss
Elimination”, “sheet 2” to “Gauss Jordan” and “sheet 3” to “Matrix Inverse”.
4. For each of the methods, obtain the roots from the given system of linear equation:
6𝑤 − 7𝑥 + 3𝑦 + 8𝑧 = 72
3𝑤 + 9𝑥 − 5𝑦 − 4𝑧 = 12
−8𝑤 + 7𝑥 + 2𝑦 − 2𝑧 = 26
7𝑤 − 4𝑥 − 3𝑦 + 8𝑧 = 19
5. Create a program/syntax that will compute for the roots.
6. Show the checking for each of the methods. Create a program/syntax for this.
7. Round off answers up to 5 decimal places.
8. Save your work using a specified file name given by your instructor on your “my documents”.
NUMERICAL METHODS AND ANALYSIS – LABORATORY 6|P a g e
College of Engineering
DATA SHEET
Approved by:
Instructor
NUMERICAL METHODS AND ANALYSIS – LABORATORY 7|P a g e
College of Engineering
GRAPH:
NUMERICAL METHODS AND ANALYSIS – LABORATORY 8|P a g e
College of Engineering
DISCUSSION OF RESULTS:
NUMERICAL METHODS AND ANALYSIS – LABORATORY 9|P a g e
College of Engineering
CONCLUSION:
NUMERICAL METHODS AND ANALYSIS – LABORATORY 10 | P a g e
College of Engineering
PROBLEMS/EXERCISES:
1.) What function command is used for solving the roots of system of linear equation using
inverse matrix method? Show the syntax.
2.) Evaluate 2 Chapter problems from the book Numerical Methods for Engineers (By Chapra
and Canale) involving Gauss Elimination Method (Chapter 9) using your excel Gauss
Elimination Method worksheet.
3.) Evaluate 2 Chapter problems from the book Numerical Methods for Engineers (By Chapra
and Canale) involving Gauss Jordan Method (Chapter 9) using your excel Gauss Jordan
Method worksheet.
4.) Evaluate 2 Chapter problems from the book Numerical Methods for Engineers (By Chapra
and Canale) involving Matrix Inverse Method (Chapter 10) using your excel Matrix Inverse
Method worksheet.
NUMERICAL METHODS AND ANALYSIS – LABORATORY 11 | P a g e