1 of 66

VECTORS

1

2 of 66

MATRICES

2

3 of 66

MATRICES

3

4 of 66

Determinant of a MATRICES

CISE301_Topic3

4

5 of 66

Adding and Multiplying Matrices

CISE301_Topic3

5

6 of 66

Systems of Linear Equations

CISE301_Topic3

6

7 of 66

Solutions of Linear Equations

CISE301_Topic3

7

8 of 66

Solutions of Linear Equations

  • A set of equations is inconsistent if there exists no solution to the system of equations:

CISE301_Topic3

8

9 of 66

Solutions of Linear Equations

  • Some systems of equations may have infinite number of solutions

CISE301_Topic3

9

10 of 66

Graphical Solution of Systems of�Linear Equations

CISE301_Topic3

10

Solution

x1=1, x2=2

11 of 66

Cramer’s Rule is Not Practical

CISE301_Topic3

11

12 of 66

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.

CISE301_Topic3

12

13 of 66

Elementary Row Operations

  • Adding a multiple of one row to another

  • Multiply any row by a non-zero constant

CISE301_Topic3

13

14 of 66

Example�Forward Elimination

CISE301_Topic3

14

15 of 66

Example�Forward Elimination

CISE301_Topic3

15

16 of 66

Example�Forward Elimination

CISE301_Topic3

16

17 of 66

Example�Backward Substitution

CISE301_Topic3

17

18 of 66

Forward Elimination

CISE301_Topic3

18

19 of 66

Forward Elimination

CISE301_Topic3

19

20 of 66

Backward Substitution

CISE301_Topic3

20

21 of 66

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. Solve for xn ,xn-1,…x1.

CISE301_Topic3

21

22 of 66

Example 1

CISE301_Topic3

22

23 of 66

Example 1

CISE301_Topic3

23

24 of 66

Example 1�Backward Substitution

CISE301_Topic3

24

25 of 66

Determinant

CISE301_Topic3

25

26 of 66

How Many Solutions Does a System of Equations AX=B Have?

CISE301_Topic3

26

27 of 66

Examples

CISE301_Topic3

27

28 of 66

Pseudo-Code: Forward Elimination

Do k = 1 to n-1

Do i = k+1 to n

factor = ai,k / ak,k

Do j = k+1 to n

ai,j = ai,j – factor * ak,j

End Do

bi = bi – factor * bk

End Do

End Do

CISE301_Topic3

28

29 of 66

Pseudo-Code: Back Substitution

xn = bn / an,n

Do i = n-1 downto 1

sum = bi

Do j = i+1 to n

sum = sum – ai,j * xj

End Do

xi = sum / ai,i

End Do

CISE301_Topic3

29

30 of 66

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

CISE301_Topic3

30

31 of 66

Example 2

CISE301_Topic3

31

32 of 66

Example 2�Initialization step

CISE301_Topic3

32

Scale vector:

disregard sign

find largest in magnitude in each row

33 of 66

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.

CISE301_Topic3

33

34 of 66

Example 2�Forward Elimination-- Step 1: eliminate x1

CISE301_Topic3

34

35 of 66

Example 2�Forward Elimination-- Step 1: eliminate x1

CISE301_Topic3

35

First pivot equation

36 of 66

Example 2�Forward Elimination-- Step 2: eliminate x2

CISE301_Topic3

36

37 of 66

Example 2�Forward Elimination-- Step 3: eliminate x3

CISE301_Topic3

37

Third pivot equation

38 of 66

Example 2�Backward Substitution

CISE301_Topic3

38

39 of 66

Example 3

CISE301_Topic3

39

40 of 66

Example 3�Initialization step

CISE301_Topic3

40

41 of 66

Example 3�Forward Elimination-- Step 1: eliminate x1

CISE301_Topic3

41

42 of 66

Example 3�Forward Elimination-- Step 1: eliminate x1

CISE301_Topic3

42

43 of 66

Example 3�Forward Elimination-- Step 2: eliminate x2

CISE301_Topic3

43

44 of 66

Example 3�Forward Elimination-- Step 2: eliminate x2

CISE301_Topic3

44

45 of 66

Example 3�Forward Elimination-- Step 3: eliminate x3

CISE301_Topic3

45

46 of 66

Example 3�Forward Elimination-- Step 3: eliminate x3

CISE301_Topic3

46

47 of 66

Example 3�Backward Substitution

CISE301_Topic3

47

48 of 66

How Do We Know If a Solution is Good or Not

Given AX=B

X is a solution if AX-B=0

Compute the residual vector R= AX-B

Due to rounding error, R may not be zero

CISE301_Topic3

48

49 of 66

How Good is the Solution?

CISE301_Topic3

49

50 of 66

Remarks:

  • We use index vector to avoid the need to move the rows which may not be practical for large problems.
  • If we order the equation as in the last value of the index vector, we have a 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.

CISE301_Topic3

50

51 of 66

Tridiagonal Systems

Tridiagonal Systems:

  • The non-zero elements are in the main diagonal, super diagonal and subdiagonal.
  • aij=0 if |i-j| > 1

CISE301_Topic3

51

52 of 66

Tridiagonal Systems

  • Occur in many applications
  • Needs less storage (4n-2 compared to n2 +n for the general cases)
  • Selection of pivoting rows is unnecessary (under some conditions)
  • Efficiently solved by Gaussian elimination

CISE301_Topic3

52

53 of 66

Algorithm to Solve Tridiagonal Systems

  • Based on Naive Gaussian elimination.
  • As in previous Gaussian elimination algorithms
    • Forward elimination step
    • Backward substitution step
  • Elements in the super diagonal are not affected.
  • Elements in the main diagonal, and B need updating

CISE301_Topic3

53

54 of 66

Tridiagonal System

CISE301_Topic3

54

55 of 66

Diagonal Dominance

CISE301_Topic3

55

56 of 66

Diagonal Dominance

CISE301_Topic3

56

57 of 66

Diagonally Dominant Tridiagonal System

  • A tridiagonal system is diagonally dominant if

  • Forward Elimination preserves diagonal dominance

CISE301_Topic3

57

58 of 66

Solving Tridiagonal System

CISE301_Topic3

58

59 of 66

Example

CISE301_Topic3

59

60 of 66

Example

CISE301_Topic3

60

61 of 66

Example�Backward Substitution

  • After the Forward Elimination:

  • Backward Substitution:

CISE301_Topic3

61

62 of 66

Gauss-Jordan Method

  • The method reduces the general system of equations AX=B to IX=B where I is an identity matrix.

  • Only Forward elimination is done and no backward substitution is needed.

  • It has the same problems as Naive Gaussian elimination and can be modified to do partial scaled pivoting.

  • It takes 50% more time than Naive Gaussian method.

CISE301_Topic3

62

63 of 66

Gauss-Jordan Method�Example

CISE301_Topic3

63

64 of 66

Gauss-Jordan Method�Example

CISE301_Topic3

64

65 of 66

Gauss-Jordan Method�Example

CISE301_Topic3

65

66 of 66

Gauss-Jordan Method�Example

CISE301_Topic3

66