Applied numerical methods lec4

17
1 Chapter 5 Bracketing Method

Transcript of Applied numerical methods lec4

Page 1: Applied numerical methods lec4

1

Chapter 5

Bracketing Method

Page 2: Applied numerical methods lec4

2

• Easy

• But, not easy

• How about these?

a

acbbxcbxax

2

40

22

? 02345 xfexdxcxbxax

Roots of Equations

? 0)3sin()10cos(

? 0sin

xxx

xxx

Page 3: Applied numerical methods lec4

Graphical Approach

• Make a plot of the

function f(x) and

observe where it

crosses the x-axis,

i.e. f(x) = 0

• Not very practical

but can be used to

obtain rough

estimates for roots

• These estimates can

be used as initial

guesses for numerical

methods that we’ll

study here.

Using MATLAB, plot f(x)=sin(10x)+cos(3x)

Page 4: Applied numerical methods lec4

4

Why Called Bracketing Methods?

They require two initial guesses which “bracket”

either side of the root.

Page 5: Applied numerical methods lec4

5

Example1: the parachutist problem

Given m = 68.1 kg, v = 40 m/s, t = 10 s, g = 9.8 m/s2, find the corresponding c

Graphical Methods

40138667

40116889

1 146843010168 )(

.)(

).(.)()(

.)./()/( cctmc ec

ec

vec

gmcf

)()/( tmce

c

gmv 1

Make a plot of the function and observe where it crosses the x axis

Solution:

c f(c)

4 34.115

8 17.653

12 6.067

16 -2.269

20 -8.401

Root is between 12 and 16

Page 6: Applied numerical methods lec4

6

Estimate Properties of Roots By Graphical Methods

From (a) and (c):

if both f(xl) and f(xu) have the same sign, there must be 0 or even number of roots

From (b) and (d):

if f(xl) and f(xu) have different signs, there must be 1 or odd number of roots

Exceptions:

multiple roots

f(x) = (x-2)2(x-4)

discontinuous f(x)

Page 7: Applied numerical methods lec4

7

Find x such that f(x) = 0:

Step 1: Choose lower xl and upper xu such that f(xl)f(xu) < 0

Step 2: an estimate of the root

Step 3: Make the evaluations to determine in which interval the root lies:

(a) if f(xl)f(xr) < 0, the root lies in the lower interval; set xu = xr and

return to Step 2.

(b) if f(xl)f(xr) > 0, the root lies in the upper interval; set xl = xr and

return to Step 2.

(c) if f(xl)f(xr) = 0, the root = xr, stop.

Bisection Method

2

ulr

xxx

Page 8: Applied numerical methods lec4

8

s

t

rt

tx

xx

%100

||

||

snewr

oldr

newr

ax

xx

%

||

||100

Error Estimates

But, we don’t know xt !

As an alternative, use:

true relative error εt, approximate relative error εa,

and acceptable error εs

Page 9: Applied numerical methods lec4

9

Example 1

Page 10: Applied numerical methods lec4

10

Page 11: Applied numerical methods lec4

11

Example 2

Page 12: Applied numerical methods lec4

12

f(x) = sin x – x3

Page 13: Applied numerical methods lec4

13

Page 14: Applied numerical methods lec4

14

Conservative Overestimate by a

a is always larger than t !

a

t

Page 15: Applied numerical methods lec4

15

Bisection Method

Pros

• Easy

• Always finds a root

• Number of iterations

required to attain an

absolute error.

Cons

• Slow

• Need to find initial

guesses for xl and xu

• No account is taken

of the fact that if f(xl)

is closer to zero, it is

likely that root is

closer to xl .

Page 16: Applied numerical methods lec4

16

Page 17: Applied numerical methods lec4

17

Incremental Search and Determining Initial Guesses

• For every interval xi – xi+1, apply bisection or false-

position method to find the roots in the interval

• Only roots in x4-x5 will be found