today’s class briefly summarize the first two parts error analysis roots of equation linear...

42
Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture 7 1 Prof. Jinbo Bi CSE, UConn

Upload: clinton-morrison

Post on 13-Jan-2016

222 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Today’s class

• Briefly summarize the first two parts• Error analysis• Roots of equation

• Linear Algebraic Equations• Gauss Elimination

Numerical Methods, Lecture 7 1

Prof. Jinbo Bi CSE, UConn

Page 2: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Round-off errors are caused because exact numbers cannot be expressed in a fixed number of digits as with computer representations

• Round-off errors occurs from imprecision in representation of data

• Truncation errors result from a numerical approximation in place of an exact analytical formula• Finite divided difference, Infinite series

Error Analysis

Numerical Methods, Lecture 7 2

Prof. Jinbo Bi CSE, UConn

Page 3: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Bisection• 2 initial guesses, slow convergence, will not

diverge

• False-position• 2 initial guesses, slow-medium convergence,

will not diverge

Roots of equations

Numerical Methods, Lecture 7 3

Prof. Jinbo Bi CSE, UConn

Page 4: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Newton-Raphson• 1 initial guess, fast convergence, may

diverge

• Secant• 2 initial guesses, medium-fast convergence,

may diverge

Roots of equations

Numerical Methods, Lecture 7 4

Prof. Jinbo Bi CSE, UConn

Page 5: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Muller• 3 initial guesses, medium-fast convergence,

may diverge, only polynomials, complex roots

• Bairstow• 2 initial guesses, medium-fast convergence,

may diverge, only polynomials, complex roots

Roots of equations

Numerical Methods, Lecture 7 5

Prof. Jinbo Bi CSE, UConn

Page 6: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Linear Algebraic Equations• Solving for roots gave us solutions to

equations of the form:

• A more general problem would be to solve the following n equations simultaneously

6Numerical Methods, Lecture 7 6

Prof. Jinbo Bi CSE, UConn

Page 7: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Linear Algebraic Equations• A linear algebraic system is a system of

equations where all the functions are linear

Numerical Methods, Lecture 7 7

Prof. Jinbo Bi CSE, UConn

Page 8: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Linear Algebraic Equations• Graphical solutions

• Plot the functions and the solution is the intersection point of the functions

• For two dimensional linear systems, each equation is a line

• For three dimensional linear systems each equation is a plane

Numerical Methods, Lecture 7 8

Prof. Jinbo Bi CSE, UConn

Page 9: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Linear Algebraic Equations• Example:

Numerical Methods, Lecture 7 9

Prof. Jinbo Bi CSE, UConn

Page 10: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Linear Algebraic Equations• Singular system (no solution)

Numerical Methods, Lecture 7 10

Prof. Jinbo Bi CSE, UConn

Page 11: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Linear Algebraic Equations• Singular system (infinite solutions)

Numerical Methods, Lecture 7 11

Prof. Jinbo Bi CSE, UConn

Page 12: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Linear Algebraic Equations• Ill-conditioned system

Numerical Methods, Lecture 7 12

Prof. Jinbo Bi CSE, UConn

Page 13: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Linear Algebraic Equations• Graphical methods work only for second

and maybe third order systems• Not precise• Useful visualization tool

Numerical Methods, Lecture 7 13

Prof. Jinbo Bi CSE, UConn

Page 14: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Linear Algebraic Equations• In matrix form

• where A is a n x n matrix, and X and B are n x 1 vectors.

Numerical Methods, Lecture 7 14

Prof. Jinbo Bi CSE, UConn

Page 15: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Matrices

• Definitions:• Symmetric matrix• Diagonal matrix• Identity matrix (I)

Numerical Methods, Lecture 7 15

Prof. Jinbo Bi CSE, UConn

Page 16: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Matrices• Definitions:

• Upper triangular

• Lower triangular

• Banded

• Transpose

Numerical Methods, Lecture 7 16

Prof. Jinbo Bi CSE, UConn

Page 17: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Matrix Operations

• Addition

• Subtraction

• Multiplication

Numerical Methods, Lecture 7 17

Prof. Jinbo Bi CSE, UConn

Page 18: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Addition/Subtraction - O(n2)• Multiplication - O(n3)

Matrix operations

Numerical Methods, Lecture 7 18

Prof. Jinbo Bi CSE, UConn

Page 19: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• If A is non-singular and square, then A-1 is the inverse such that

Inverse Matrices

Numerical Methods, Lecture 7 19

Prof. Jinbo Bi CSE, UConn

Page 20: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• In matrix form

• where A is a n x n matrix, and X and B are n x 1 vectors.

Linear algebraic equations

Numerical Methods, Lecture 7 20

Prof. Jinbo Bi CSE, UConn

Page 21: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• We need to solve for X

Linear algebraic equations

Numerical Methods, Lecture 7 21

Prof. Jinbo Bi CSE, UConn

Page 22: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Linear Equations

• How do we get A-1?• It is non-trivial• Not very efficient if solved by hand

• Usually use other methods to solve for X• Gauss Elimination• LU Decomposition

Numerical Methods, Lecture 7 22

Prof. Jinbo Bi CSE, UConn

Page 23: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Given a second-order matrix A, the determinant D is defined as follows:

• Given a third-order matrix A, the determinant D is defined as follows:

Determinants, Cramer’s Rule

Numerical Methods, Lecture 7 23

Prof. Jinbo Bi CSE, UConn

Page 24: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Using determinants to solve a linear system

• Cramer’s rule• Replace a column of coefficients in matrix A

with the B vector and find determinant

Determinants, Cramer’s Rule

Numerical Methods, Lecture 7 24

Prof. Jinbo Bi CSE, UConn

Page 25: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

25

Cramer’s rule example

Numerical Methods, Lecture 7 25

Prof. Jinbo Bi CSE, UConn

Page 26: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Extension of elimination of unknowns as a systematic algorithm

• Two steps• Elimination of unknowns• Back substitution

Gauss Elimination

Numerical Methods, Lecture 7 26

Prof. Jinbo Bi CSE, UConn

Page 27: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Forward elimination

• Eliminate x1 from row 2• Multiply row 1 by a21/a11

Gauss Elimination

Numerical Methods, Lecture 7 27

Prof. Jinbo Bi CSE, UConn

Page 28: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Eliminate x1 from row 2• Subtract row 1 from row 2

• Eliminate x1 from all other rows in the same way

• Then eliminate x2 from rows 3 to n and so on

Gauss Elimination

Numerical Methods, Lecture 7 28

Prof. Jinbo Bi CSE, UConn

Page 29: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Forward elimination

• Back substitute to solve for x

Gauss Elimination

Numerical Methods, Lecture 7 29

Prof. Jinbo Bi CSE, UConn

Page 30: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Back substitution

• In general,

Gauss Elimination

Numerical Methods, Lecture 7 30

Prof. Jinbo Bi CSE, UConn

Page 31: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Gauss Elimination

Numerical Methods, Lecture 7 31

Prof. Jinbo Bi CSE, UConn

Page 32: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Computational complexity• 2n3/3 + O(n2)• three orders of increase for every order of

increase in n• Most of the effort is incurred in the

elimination step

Gauss elimination

Numerical Methods, Lecture 7 32

Prof. Jinbo Bi CSE, UConn

Page 33: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Things to worry about• Division by zero• Round-off error• Ill-conditioned system

Gauss elimination

Numerical Methods, Lecture 7 33

Prof. Jinbo Bi CSE, UConn

Page 34: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Ill-conditioned system example

Gauss elimination

Numerical Methods, Lecture 7 34

Prof. Jinbo Bi CSE, UConn

Page 35: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Ill-conditioned system example

Gauss elimination

Numerical Methods, Lecture 7 35

Prof. Jinbo Bi CSE, UConn

Page 36: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• If the determinant is close to zero, the system is ill-conditioned

• If the determinant is exactly zero, the system is singular

• It is difficult to specify how close to zero, as the magnitude of the determinant can be changed by multiplying by a constant without changing the solution

Gauss elimination

Numerical Methods, Lecture 7 36

Prof. Jinbo Bi CSE, UConn

Page 37: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Basic idea is to remove divide by zero if a11 is zero

• Swap the row with the largest element with the top row

Gauss elimination with pivoting

Numerical Methods, Lecture 7 37

Prof. Jinbo Bi CSE, UConn

Page 38: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Gauss elimination with pivoting

Numerical Methods, Lecture 7 38

Prof. Jinbo Bi CSE, UConn

Page 39: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Gauss elimination with pivoting

Numerical Methods, Lecture 7 39

Prof. Jinbo Bi CSE, UConn

Page 40: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• It is sometimes useful to scale the equations so that the largest coefficient in any row is 1

• Example

Gauss elimination with scaling

Numerical Methods, Lecture 7 40

Prof. Jinbo Bi CSE, UConn

Page 41: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

• Example

Gauss elimination with scaling

Numerical Methods, Lecture 7 41

Prof. Jinbo Bi CSE, UConn

Page 42: Today’s class Briefly summarize the first two parts Error analysis Roots of equation Linear Algebraic Equations Gauss Elimination Numerical Methods, Lecture

Next class

• LU Decomposition• Read Chapter 10

Numerical Methods, Lecture 7 42

Prof. Jinbo Bi CSE, UConn