# Mujahed AlDhaifallah (Term 342) Read Chapter 9 of the textbook

## Presentation on theme: "Mujahed AlDhaifallah (Term 342) Read Chapter 9 of the textbook"— Presentation transcript:

Mujahed AlDhaifallah (Term 342) Read Chapter 9 of the textbook
EE 3561 : - Computational Methods Unit 3: Solution of Systems of Linear Equations Mujahed AlDhaifallah (Term 342) Read Chapter 9 of the textbook EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Systems of linear equations
Coefficient Matrix Unknown Vector RHS Vector EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Solutions of linear equations
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Solutions of linear equations
A set of equations is inconsistent if there exist no solution to the system of equations EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Solutions of linear equations
Some systems of equations may have infinite number of solutions EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Graphical Solution of Systems of Linear Equations
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Cramer’s Rule is not practical
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Lecture 6 Naive Gaussian Elimination
Examples EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Naive Gaussian Elimination
The method consists of two steps Forward Elimination: the system is reduced to upper triangular form. A sequence of elementary operations is used. Backward substitution: Solve the system starting from the last variable. EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Elementary Row operations
Adding a multiple of one row to another Multiply any row by a non-zero constant EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example Forward Elimination
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example Forward Elimination
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example Forward Elimination
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example Backward substitution
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Forward Elimination EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Forward Elimination EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Backward substitution
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

How many solutions does a system of equations AX=B have?
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

How do we know if a solution is good or not
Given AX=B X is a solution if AX-B=0 Due to computation error AX-B may not be zero Compute the residuals R=|AX-B| One possible test is ????? EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Determinant EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Linear Systems Types Singular Systems EE3561_Unit 3
(c)AL-DHAIFALLAH1435

Detecting Singularity
After completing the elimination step, the determinant can be evaluated as the product of the diagonal elements. One can detect singularity by the fact that the determinant of a singular system is zero. EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Problems with Naive Gaussian Elimination
The Naive Gaussian Elimination may fail for very simple cases. (The pivoting element is zero). Very small pivoting element may result in , serious computation errors EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Possible solution Equations Permutation: Naive Gaussian elimination method works well in the above two examples if the equations are first permuted, i.e., arranged as The procedure that will do so is called “Gaussian elimination with scaled partial pivoting”. EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Gaussian Elimination with Scaled Partial Pivoting
In Gaussian elimination method, the order in which the equations are used as pivoting equations is the natural order {1, 2, 3, · · · , n}. To overcome the problems that Naive Guassian elimination procedure face, we choose an order which is different than the natural used in forward elimination method. This is called partial pivoting. The most important step in this method is to determine the pivot equation EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Gaussian Elimination with Scaled Partial Pivoting
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Scaled Partial Pivoting Procedure
Let l0 = {1, 2, 3, · · · , n}. This vector is called the “index vector”. Define This vector is called the “Scale Vector” and is fixed for all operations. This means that si =absolute value of the maximum element in row i. For iteration 1, define ratio#1 as That is divide the absolute value of the elements of the first column by the corresponding elements in the “Scaled Vector”. EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Scaled Partial Pivoting Procedure
Choose the equation which give the greatest ratio as the first pivoting equation. Assume the greatest ratio is Set the new index vector to be i.e., interchange the place of 1 and i in l0 to get l1. Then do the elimination as in the Naive Gaussian elimination method by taking raw i as the pivot raw and aii as the pivot element. Repeat steps 3 to 6 for n − 1 iterations. EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 2 EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 2 Initialization step
Scale vector: disregard sign find largest in magnitude in each row EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Why index vector? Index vectors are used because it is much easier to exchange a single index element compared to exchanging the values of a complete row. In practical problems with very large N, exchanging the contents of rows may not be practical since they could be stored at different locations. EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 2 Forward Elimination-- Step 1: eliminate x1
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 2 Forward Elimination-- Step 1: eliminate x1
First pivot equation EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 2 Forward Elimination-- Step 2: eliminate x2
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 2 Forward Elimination-- Step 2: eliminate x2
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 2 Forward Elimination-- Step 3: eliminate x3
Third pivot equation Determinant = (-1)3*(-1.5)(-2.5)(2)(4) = 30- EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 2 Backward substitution
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 3 EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 3 Initialization step
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 3 Forward Elimination-- Step 1: eliminate x1
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 3 Forward Elimination-- Step 1: eliminate x1
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 3 Forward Elimination-- Step 2: eliminate x2
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 3 Forward Elimination-- Step 2: eliminate x2
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 3 Forward Elimination-- Step 3: eliminate x3
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 3 Forward Elimination-- Step 3: eliminate x3
Determinant = (-1)2*(0.8448)* ( )*(-10.5)*(4) = EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Example 3 Backward substitution
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

How good is the solution?
EE3561_Unit 3 (c)AL-DHAIFALLAH1435

Remarks: We use index vector to avoid the need to move the rows which may not be practical for large problems. If you order equation as in the last value of the index vector, you have triangular form. Scale vector is formed by taking maximum in magnitude in each row. Scale vector does not change. The original matrices A and B are used in Checking the residuals. EE3561_Unit 3 (c)AL-DHAIFALLAH1435