51
file: roots.ppt p. 1 ROOTS OF EQUATIONS ENGR 351 Numerical Methods for Engineers Southern Illinois University Carbondale College of Engineering Dr. L.R. Chevalier Dr. B.A. DeVantier

Roots00 posted

Embed Size (px)

Citation preview

Page 1: Roots00 posted

file: roots.ppt p. 1

ROOTS OF EQUATIONS

ENGR 351

Numerical Methods for Engineers

Southern Illinois University Carbondale

College of Engineering

Dr. L.R. Chevalier

Dr. B.A. DeVantier

Page 2: Roots00 posted

file: roots.ppt p. 2

Quadratic Formula

xb b ac

a

f x ax bx c

2

2

4

2

0( )

This equation gives us the roots of the algebraic functionf(x)

i.e. the value of x that makes f(x) = 0

How can we solve for f(x) = e-x - x?

Page 3: Roots00 posted

file: roots.ppt p. 3

Roots of Equations

• Plot the function and determine where it crosses the x-axis

• Lacks precision• Trial and error

f(x)=e-x-x

-2

0

2

4

6

8

10

-2 -1 0 1 2

x

f(x)

Page 4: Roots00 posted

file: roots.ppt p. 4

Overview of Methods

• Bracketing methodsGraphing method

Bisection method

False position

• Open methodsOne point iteration

Newton-Raphson

Secant method

Page 5: Roots00 posted

file: roots.ppt p. 5

• Understand the graphical interpretation of a root

• Know the graphical interpretation of the false-position method and why it is usually superior to the bisection method

• Understand the difference between bracketing and open methods for root location

Specific Study Objectives

Page 6: Roots00 posted

file: roots.ppt p. 6

• Understand the concepts of convergence and divergence.

• Know why bracketing methods always converge, whereas open methods may sometimes diverge

• Realize that convergence of open methods is more likely if the initial guess is close to the true root

Specific Study Objectives

Page 7: Roots00 posted

file: roots.ppt p. 7

• Know the fundamental difference between the false position and secant methods and how it relates to convergence

• Understand the problems posed by multiple roots and the modification available to mitigate them

• Use the techniques presented to find the root of an equation

• Solve two nonlinear simultaneous equations

Specific Study Objectives

Page 8: Roots00 posted

file: roots.ppt p. 8

Bracketing Methods

• Graphical

• Bisection method

• False position method

Page 9: Roots00 posted

file: roots.ppt p. 9

Graphical(limited practical value)

x

f(x)

x

f(x)

x

f(x)

x

f(x)

consider lowerand upper boundsame sign,no roots or even # of roots

opposite sign,odd # of roots

Page 10: Roots00 posted

file: roots.ppt p. 10

Bisection Method

• Takes advantage of sign changing

• f(xl)f(xu) < 0 where the subscripts refer to lower and upper bounds

• There is at least one real root

x

f(x)

x

f(x)

x

f(x)

Page 11: Roots00 posted

file: roots.ppt p. 11

Algorithm• Choose xu and xl. Verify sign change

f(xl)f(xu) < 0

• Estimate root

xr = (xl + xu) / 2

• Determine if the estimate is in the lower or upper subinterval

f(xl)f(xr) < 0 then xu = xr RETURN

f(xl)f(xr) >0 then xl = xr RETURN

f(xl)f(xr) =0 then root equals xr - COMPLETE

Page 12: Roots00 posted

file: roots.ppt p. 12

Error

a

present approx previous approx

present

.100

Let’s consider an example problem:

Page 13: Roots00 posted

file: roots.ppt p. 13

•f(x) = e-x - x

•xl = -1 xu = 1

EXAMPLE

Use the bisection method to determine the root

3.718282

-0.63212

-2

0

2

4

6

8

10

-2 -1 0 1 2

x

f(x)

Page 14: Roots00 posted

file: roots.ppt p. 14

SOLUTION

3.718282

-0.63212

1

-2

0

2

4

6

8

10

-2 -1 0 1 2

x

f(x)

Page 15: Roots00 posted

file: roots.ppt p. 15

-0.63212

1

0.106531

-2

0

2

-1 0 1 2

x

f(x)SOLUTION

Page 16: Roots00 posted

file: roots.ppt p. 16

False Position Method

• “Brute Force” of bisection method is inefficient

• Join points by a straight line

• Improves the estimate

• Replacing the curve by a straight line gives the “false position”

Page 17: Roots00 posted

file: roots.ppt p. 17

xl

xu

f(xl)

f(xu)next estimate, xr

f x

x x

f x

x x

x xf x x x

f x f x

l

r l

u

r u

r uu l u

l u

Based on similar triangles

Page 18: Roots00 posted

file: roots.ppt p. 18

EXAMPLE

Determine the root of the following equation using the false position method starting with an initial estimate of xl=4.55 and xu=4.65

f(x) = x3 - 98

-40

-30

-20

-10

0

10

20

30

4 4.5 5

x

f(x)

Page 19: Roots00 posted

file: roots.ppt p. 19

Pitfalls of False Position Method

f(x)=x10-1

-5

05

10

15

2025

30

0 0.5 1 1.5

x

f(x)

Page 20: Roots00 posted

file: roots.ppt p. 20

Open Methods

• Simple one point iteration

• Newton-Raphson method

• Secant method

• Multiple roots

• In the previous bracketing methods, the root is located within an interval prescribed by an upper and lower boundary

Page 21: Roots00 posted

file: roots.ppt p. 21

Open Methods cont.• Such methods are said to be convergent

solution moves closer to the root as the computation progresses

• Open methodsingle starting value

two starting values that do not necessarily bracket the root

• These solutions may divergesolution moves farther from the root as the

computation progresses

Page 22: Roots00 posted

file: roots.ppt p. 22

The tangentgives next estimate.xi

f(x)

x

f(xi)

xi+1

f(xi+1 )

Page 23: Roots00 posted

file: roots.ppt p. 23

Solution can “overshoot”the root and potentiallydiverge

x0

f(x)

x

x1x2

Page 24: Roots00 posted

file: roots.ppt p. 24

Simple one point iteration

• Open methods employ a formula to predict the root

• In simple one point iteration, rearrange the function f(x) so that x is on the left hand side of the equationi.e. for f(x) = x2 - 2x + 3 = 0

x = (x2 + 3) / 2

Page 25: Roots00 posted

file: roots.ppt p. 25

Simple one point iteration

• In simple one point iteration, rearrange the function f(x) so that x is on the left hand side of the equationi.e. for f(x) = sin x = 0

x = sin x + x

• Let x = g(x)

• New estimate based onx i+1 = g(xi)

Page 26: Roots00 posted

file: roots.ppt p. 26

EXAMPLE(solution presented in notes)

• Consider f(x) = e-x -3x

• g(x) = e-x / 3

• Initial guess x = 0

-6-4-202468

10121416

-2 -1 0 1 2

x

f(x)

Page 27: Roots00 posted

file: roots.ppt p. 27

Initial guess 0.000

g(x) f(x) a

0.333 -0.283

0.239 0.071 39.561

0.263 -0.018 9.016

0.256 0.005 2.395

0.258 -0.001 0.612

0.258 0.000 0.158

0.258 0.000 0.041

-6-4-202468

10121416

-2 -1 0 1 2

x

f(x)

Page 28: Roots00 posted

file: roots.ppt p. 28

Newton Raphson

tangent

dy

dxf

f xf x

x x

rearrange

x xf x

f x

ii

i i

i ii

i

'

'

'

0

1

1

f(xi)

xi

tangent

xi+1

Page 29: Roots00 posted

file: roots.ppt p. 29

Newton RaphsonPitfalls

Page 30: Roots00 posted

file: roots.ppt p. 30

EXAMPLE

Use the Newton Raphson method to determine the root off(x) = x2 - 11 using an initial guess of xi = 3 -20

0

20

40

60

80

100

0 2 4 6 8 10

x

f(x)

Page 31: Roots00 posted

file: roots.ppt p. 31

In your program code, check for problems of divergence

• Include an upper limit on the number of iterations

• Establish a tolerance, s

• Check to see if a is increasing

What if derivative is difficult to evaluate?

SECANT METHOD

Page 32: Roots00 posted

file: roots.ppt p. 32

Secant method

f x

f x f x

x xi i

i i

'

1

1

Approximate derivative using a finite divided difference

What is this? HINT: dy / dx = y / x

Substitute this into the formula for Newton Raphson

Page 33: Roots00 posted

file: roots.ppt p. 33

Secant method

ii

iiiii

i

iii

xfxf

xxxfxx

xf

xfxx

1

11

1 '

Substitute finite difference approximation for thefirst derivative into this equation for Newton Raphson

Page 34: Roots00 posted

file: roots.ppt p. 34

Secant method

• Requires two initial estimates• f(x) is not required to change signs, therefore this

is not a bracketing method

ii

iiiii xfxf

xxxfxx

1

11

Page 35: Roots00 posted

file: roots.ppt p. 35

x

f(x)

1

2

new est.

x

f(x)

1

new est.

2

FALSE POSITION

SECANT METHOD

The new estimateis selected from theintersection with thex-axis

Page 36: Roots00 posted

file: roots.ppt p. 36

Multiple Roots

• Corresponds to a point where a function is tangential to the x-axis

• i.e. double rootf(x) = x3 - 5x2 + 7x -3

f(x) = (x-3)(x-1)(x-1)

i.e. triple root

f(x) = (x-3)(x-1)3

-4

-2

0

2

4

6

8

10

0 1 2 3 4

x

f(x) multiple root

Page 37: Roots00 posted

file: roots.ppt p. 37

Difficulties

• Bracketing methods won’t work

• Limited to methods that may diverge

-4

-2

0

2

4

6

8

10

0 1 2 3 4

x

f(x) multiple root

Page 38: Roots00 posted

file: roots.ppt p. 38

• f(x) = 0 at root

• f '(x) = 0 at root

• Hence, zero in the denominator for Newton-Raphson and Secant Methods

• Write a “DO LOOP” to check is f(x) = 0 before continuing

-4

-2

0

2

4

6

8

10

0 1 2 3 4

xf(x) multiple root

Page 39: Roots00 posted

file: roots.ppt p. 39

Multiple Roots

x xf x f x

f x f x f xi i

i i

i i i

1 2

'

' ' '

-4

-2

0

2

4

6

8

10

0 1 2 3 4

x

f(x) multiple root

Page 40: Roots00 posted

file: roots.ppt p. 40

Systems of Non-Linear Equations

• We will later consider systems of linear equationsf(x) = a1x1 + a2x2+...... anxn - C = 0

where a1 , a2 .... an and C are constant

• Consider the following equationsy = -x2 + x + 0.5

y + 5xy = x3

• Solve for x and y

Page 41: Roots00 posted

file: roots.ppt p. 41

Systems of Non-Linear Equations cont.

• Set the equations equal to zeroy = -x2 + x + 0.5

y + 5xy = x3

• u(x,y) = -x2 + x + 0.5 - y = 0• v(x,y) = y + 5xy - x3 = 0• The solution would be the values of x and y

that would make the functions u and v equal to zero

Page 42: Roots00 posted

file: roots.ppt p. 42

Recall the Taylor Series

f x f x f x hf x

hf x

h

f x

nh R

where h step size x x

i i ii i

ni n

n

i i

12 3

1

2 3'

' '

!

' ' '

!

!. . . . . .

Page 43: Roots00 posted

file: roots.ppt p. 43

Write a first order Taylor series with respect to u and v

u uu

xx x

u

yy y

v vv

xx x

v

yy y

i ii

i ii

i i

i ii

i ii

i i

1 1 1

1 1 1

The root estimate corresponds to the point whereui+1 = vi+1 = 0

Page 44: Roots00 posted

file: roots.ppt p. 44

Therefore

x xu

v

yv

u

yu

x

v

y

u

y

v

x

y yu

v

yv

u

yu

x

v

y

u

y

v

x

i i

ii

i

i i i i

i i

ii

i

i i i i

1

1

This is a 2 equation version of Newton-Raphson

Page 45: Roots00 posted

file: roots.ppt p. 45

Therefore

x xu

v

yv

u

yu

x

v

y

u

y

v

x

y yu

v

yv

u

yu

x

v

y

u

y

v

x

i i

ii

i

i i i i

i i

ii

i

i i i i

1

1

THE DENOMINATOROF EACH OF THESEEQUATIONS ISFORMALLYREFERRED TOAS THE DETERMINANTOF THEJACOBIAN

This is a 2 equation version of Newton-Raphson

Page 46: Roots00 posted

file: roots.ppt p. 46

EXAMPLE

• Determine the roots of the following nonlinear simultaneous equationsy = -x2 + x + 0.5

y + 5xy = x3

• Use and initial estimate of x=0, y=1

Page 47: Roots00 posted

file: roots.ppt p. 47

APPLIED PROBLEM

The concentration of pollutant bacteria C in a lakedecreases according to:

Determine the time required for the bacteria to be reduced to 10 using Newton-Raphson method.

C e et t 80 202 0 1.

Page 48: Roots00 posted

file: roots.ppt p. 48

You buy a $20 K piece of equipment for nothing downand $5K per year for 5 years. What interest rate are you paying? The formula relating present worth (P), annualpayments (A), number of years (n) and the interest rate(i) is:

A Pi i

i

n

n

1

1 1

Use the bisection method

APPLIED PROBLEM

Page 49: Roots00 posted

file: roots.ppt p. 49

PREVIOUS QUIZGraphically illustrate the Newton Raphson Method and bi-section method for finding the roots of an equation on graphs provided. Only show two iterations. Be sureto select initial guesses which avoid pitfalls (i.e. zeroslope).

Page 50: Roots00 posted

file: roots.ppt p. 50

PREVIOUS QUIZ

Given the Taylor series approximation, describe thedetail given by a) zero order approximation; b) firstorder approximation; c) second order approximation.

f x f x f x hf x

hf x

h

f x

nh R

where h step size x x

i i ii i

ni n

n

i i

12 3

1

2 3'

' '

!

' ' '

!

!. . . . . .

Page 51: Roots00 posted

file: roots.ppt p. 51

PREVIOUS EXAM QUESTION

Given the equation:

f(x) = x4 - 3x2 + 6x -2 = 0

a) Indicate on the graph an initial estimate for the Newton Raphson Method where

- the solution will diverge- a reasonable choice

b) Solve to three significant figures