math 175: numerical analysis ii lecturer: jomar fajardo rabajante 2 nd sem ay 2012-2013 imsp, uplb

22
MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

Upload: roger-murphy

Post on 30-Dec-2015

218 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

MATH 175: Numerical Analysis II

Lecturer: Jomar Fajardo Rabajante2nd Sem AY 2012-2013

IMSP, UPLB

Page 2: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

Numerical Methods for Linear Systems

Review (Naïve) Gaussian EliminationGiven n equations in n variables.

• Operation count for elimination step:(multiplications/divisions)

• Operation count for back substitution:

3

3nO

2

2nO

Page 3: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

Numerical Methods for Linear Systems

Overall (Naïve) Gaussian Elimination takes

Take note: we ignored here lower-order terms and we did not include row exchanges and additions/subtractions. WHAT MORE IF WE ADDED THESE STUFFS???!!! KAPOY NA!

323

323 nO

nO

nO

Page 4: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

Numerical Methods for Linear Systems

Example: Consider 10 equations in 10 unknowns. The approximate number of operations is

If our computations have round-off errors, how would our solution be affected by error magnification? Tsk… Tsk…

3343

103

Page 5: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

Numerical Methods for Linear Systems

Our goal now is to use methods that will efficiently solve our linear systems with minimized error

magnification.

Page 6: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

• When we are processing column i in Gaussian elimination, the (i,i) position is called the pivot position, and the entry in it is called the pivot entry (or simply the pivot).

• Let [A|b] be an nx(n+1) augmented matrix.

Page 7: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

STEPS:1. Begin loop (i = 1 to n–1):2. Find the largest entry (in absolute value) in

column i from row i to row n. If the largest value is zero, signal that a unique solution does not exist and stop.

3. If necessary, perform a row interchange to bring the value from step 2 into the pivot position (i,i).

Page 8: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

4. For j = i+1 to n, perform

5. End loop.6. If the (n,n) entry is zero, signal that a unique

solution does not exist and stop. Otherwise, solve for the solution by back substitution.

jii,i

j,ij RRa

aR

Page 9: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

Example:

8

12

1

1284

1244

221

8

1

12

1284

221

1244Original matrix (Matrix 0) Matrix 1

Page 10: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

8

1

12

1284

221

1244

12

0

1244Matrix 1 Matrix 2

11

44 0

Page 11: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

8

1

12

1284

221

1244

12

10

1244Matrix 1 Matrix 2

21

44 1

Page 12: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

8

1

12

1284

221

1244

12

110

1244Matrix 1 Matrix 2

21

412 –1

Page 13: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

8

1

12

1284

221

1244

2

12

110

1244Matrix 1 Matrix 2

11

412 –2

Page 14: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

8

1

12

1284

221

1244

2

12

0

110

1244Matrix 1 Matrix 2

44

44 0

Page 15: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

8

1

12

1284

221

1244

2

12

40

110

1244Matrix 1 Matrix 2

84

44 4

Page 16: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

8

1

12

1284

221

1244

2

12

040

110

1244Matrix 1 Matrix 2

124

412 0

Page 17: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

8

1

12

1284

221

1244

4

2

12

040

110

1244Matrix 1 Matrix 2

84

412 –4

Page 18: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

2

4

12

110

040

1244

4

2

12

040

110

1244

Matrix 2 Matrix 3

Page 19: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

2

4

12

110

040

1244

1

4

12

100

040

1244

Matrix 3 Final Matrix (Matrix 4)

Page 20: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

1

4

12

100

040

1244

Final Matrix Back substitution:

1x

121244x

1212z4y4x

1y44y

1z1z

Page 21: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

1

1

2

720

410

1290

8

2

12

000

1040

12191

a unique solution does not exist

Page 22: MATH 175: Numerical Analysis II Lecturer: Jomar Fajardo Rabajante 2 nd Sem AY 2012-2013 IMSP, UPLB

1st Method: Gaussian Elimination with Partial Pivoting

• There are other pivoting strategies such as the complete (or maximal) pivoting. But complete pivoting is computationally expensive.