Linear Algebraic Equations
The system can be written in a matrix format as
a11 a12 a1n x1 b1
a a22 a2 n x2 b2
21
an1 an 2 ann xn bn
We will cover
• Naive Gauss Elimination
• Techniques to Improve Solution
• Gauss-Jordan
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Gauss Elimination
• Gauss elimination is the most important algorithm to
solve systems of linear equations.
• It involves by combining equations to eliminate
unknowns.
Naive Gauss Elimination
It involves 2 phases:
1. Forward elimination phase: reduce the set of equations
to an upper triangular system.
2. Back substitution: work from the last equation up.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
• In the first step of the forward elimination phase, x1 is
eliminated from all equations except the first one.
• The coefficient of x1 in the first equation is called the
pivot element.
• The second step is to eliminate x2 from the third
equation through the nth equation.
• Do the same for all variables x3 to xn-1.
• The back-substitution phase starts from the last equation
up, to find the values of x1, x2, …, xn.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Gauss
Elimination
Pseudocode
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Example
Use Gauss elimination to solve
Carry 6 significant figures.
Solution
1) Forward elimination: eliminate x1 from equation (2):
- (0.1/3)
0.1x1 0.00333333x2 0.00666667x3 0.261667
0.1x1 7 x2 0.3 x3 19.3
7.00333 x2 0.293333 x3 19.5617
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
• Eliminate x1 from equation (3):
- (0.3/3)
• After eliminating x1 from equations (2) and (3), the
system becomes
• Eliminate x2 from equation (3):
+ (0.190000/7.00333)
• After eliminating x2 from equation (3), the system
becomes
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
2) Back Substitution: find the value of x3 from equation (3):
70.0843
x3 7.0000
10.0120
• Substitute the value of x3 in equation (2) to find the value of x2:
x2 = -2.50000
• Substitute the values of x2 and x3 in equation (1) to find the
value of x1:
x1 = 3.00000
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Pitfalls of Elimination Methods
• Division by zero
• Round-off errors
• Ill-conditioned systems:
small changes in coefficients result in large
changes in the solution.
When |A| 0.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Techniques for Improving Solutions
• Use of more significant figures
• Pivoting
• Scaling
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Pivoting
Determine the largest available coefficient in the column
below the pivot element and switch rows so that the largest
element is the pivot element.
Example
0.0003x1 3.0000x2 2.0001
1.0000x1 1.0000x2 1.0000
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Without pivoting:
With pivoting
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Scaling
Divide each row by the largest element in that row.
Example
See the example in the book, page 252.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Gauss-Jordan
• It is a variation of Gauss elimination. Both methods use
row operations to eliminate variables
• The major difference is that what an unknown is
eliminated, it is eliminated from all other equations.
• Also, all rows (equations) are normalized by dividing by
their pivot elements.
• The elimination phase produces an identity matrix.
• It does not involve the back substitution phase.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
Example
See the example and the solution in the book.
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
The Solution of Simultaneous Equations with Excel
To solve the system
See the detailed procedure to solve this system in my
website: www.ccse.kfupm.edu.sa/~salamah/matrix/
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM
The Solution of Simultaneous Equations with Matlab
To solve the system
Enter the following commands
>> A=[3 -.1 -.2; .1 7 -0.3;.3 -.2 10];
>> b=[7.85;-19.3;71.4];
>> inv(A)*b
ans =
3.0000
-2.5000
7.0000
Dr Muhammad Al-Salamah, Industrial Engineering, KFUPM