Numerical Analysis ECIV 3306 -...

33
The Islamic University of Gaza Faculty of Engineering Civil Engineering Department Numerical Analysis ECIV 3306 Chapter 5 Bracketing Methods

Transcript of Numerical Analysis ECIV 3306 -...

Page 1: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

The Islamic University of Gaza

Faculty of Engineering

Civil Engineering Department

Numerical Analysis

ECIV 3306

Chapter 5

Bracketing Methods

Page 2: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

PART II ROOTS OF EQUATIONS

Roots of Equations

Bracketing Methods

Bisection method

False Position Method

Open Methods

Simple fixed point iteration

Newton Raphson

Secant

Modified Newton Raphson

System of Nonlinear

Equations

Roots of polynomials

Muller Method

Page 3: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Study Objectives for Part Two

Page 4: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

ROOTS OF EQUATIONS

• Root of an equation: is the value of the equation variable which

make the equations = 0.0

• But

a

acbbxcbxax

2

40

22 −−

=⇒=++m

?0sin

?02345

=⇒=+

=⇒=+++++

xxx

xfexdxcxbxax

Page 5: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

ROOTS OF EQUATIONS

• Non-computer methods:

- Closed form solution (not always available)

- Graphical solution (inaccurate)

• Numerical systematic methods suitable for

computers

Page 6: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Graphical Solution

roots

• The roots exist where f(x) crosses the x-axis.

f(x)

x f(x)=0 f(x)=0

• Plot the function f(x)

Page 7: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Graphical Solution: Example

• The parachutist velocity is

• What is the drag coefficient c needed to reach a velocity of

40 m/s if m=68.1 kg, t =10 s, g= 9.8 m/s2

)(t

m

c

e1c

mgv

−=

40)1(38.667

)(

)1()(

146843.0−−=

−−=

c

tm

c

ec

cf

vec

mgcf

Check: F (14.75) = 0.059 ~ 0.0

v (c=14.75) = 40.06 ~ 40 m/s

Page 8: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Numerical Systematic Methods

I. Bracketing Methods

f(x)

x

roots

f(xl)=+ve

f(xu)=+ve

xl xu

No roots or even

number of roots

f(x)

x

roots

f(xl)=+ve

f(xu)=-ve xl xu

Odd number of roots

Page 9: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Bracketing Methods (cont.)

• Two initial guesses (xl and xu) are required for the

root which bracket the root (s).

• If one root of a real and continuous function, f(x)=0,

is bounded by values xl , xu then f(xl).f(xu) <0.

(The function changes sign on opposite sides of the root)

Page 10: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Special

Cases

Page 11: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Effect of computer scale

resolution

Page 12: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Bracketing Methods

1. Bisection Method

• Generally, if f(x) is real and continuous in the interval xl to xu

and f (xl).f(xu)<0, then there is at least one real root between

xl and xu to this function.

• The interval at which the function changes sign is located.

Then the interval is divided in half with the root lies in the

midpoint of the subinterval. This process is repeated to

obtained refined estimates.

Page 13: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

f(x)

x xu xl

f(xu)

f(xu)

xr1

f(x)

x xu xl

f(xu)

xr2

xr = ( xl + xu )/2

f(xu)

f(xr1)

f(xr2)

(f(xl).f(xr)<0): xu = xr xr = ( xl + xu )/2

Step 1: Choose lower xl and upper xu

guesses for the root such that:

f(xl).f(xu)<0

Step 2: The root estimate is:

xr = ( xl + xu )/2

Step 3: Subdivide the interval according to:

– If (f(xl).f(xr)<0) the root lies in the

lower subinterval; xu = xr and go to

step 2.

– If (f(xl).f(xr)>0) the root lies in the

upper subinterval; xl = xr and go to

step 2.

– If (f(xl).f(xr)=0) the root is xr and stop

Page 14: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Bisection Method - Termination Criteria

• For the Bisection Method εa > εt

• The computation is terminated when εa

becomes less than a certain criterion (εa < εs)

%100

:

×−

=

true

eapproximattrue

tX

XX

ErrorrelaiveTrue

ε

1

:

100%

100% (Bisection)

n n

r ra n

r

u la

u l

Approximate relative Error

X X

X

X X

X X

ε

ε

−−

= ×

−= ×

+

Page 15: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Bisection method: Example

• The parachutist velocity is

• What is the drag coefficient c needed to reach a velocity of 40

m/s if m = 68.1 kg, t = 10 s, g= 9.8 m/s2

f(c)

c

)(t

m

c

e1c

mgv

−=

40e1c

38667cf

ve1c

mgcf

c1468430

tm

c

−−=

−−=

)(.

)(

)()(

.

Page 16: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

f(x)

x 16 12

-2.269

6.067

14

f(x)

x 14 16 -0.425 -2.269

1.569

1.569

(f(12).f(14)>0): xl = 14

1. Assume xl =12 and xu=16

f(xl)=6.067 and f(xu)=-2.269

2. The root: xr=(xl+xu)/2= 14

3. Check f(12).f(14) = 6.067•1.569=9.517 >0;

the root lies between 14 and 16.

4. Set xl = 14 and xu=16, thus the new root

xr=(14+ 16)/2= 15

5. Check f(14).f(15) = 1.569•-0.425= -0.666 <0;

the root lies bet. 14 and 15.

6. Set xl = 14 and xu=15, thus the new root

xr=(14+ 15)/2= 14.5

and so on…...

15

Page 17: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Iter. Xl Xu Xr εεεεa% εεεεt%

1 12 16 14 5.279 --

2 14 16 15 6.667 1.487

3 14 15 14.5 3.448 1.896

4 14.5 15 14.75 1.695 1.204

5 14.75 15 14.875 0.84 0.641

6 14.74 14.875 14.813 0.422 0.291

• In the previous example, if the stopping criterion is εt =

0.5%; what is the root?

Bisection method: Example

Page 18: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Bisection method

Page 19: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Flow Chart –Bisection Start

Input: xl , xu , εs, maxi

f(xl). f(xu)<0

i=0

εa=1.1εs

False

while

εa> εs &

i <maxi

2

1

u r

r

x xx

i i

+=

= +

False

Stop

Print: xr , f(xr ) ,εa , i

Page 20: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

xu+xl =0

100%u l

a

u l

x x

x xε

−=

+

True

Test=f(xl). f(xr)

εa=0.0 Test=0

xu=xr Test<0

xl=xr

True

True

False

Page 21: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Bracketing Methods

2. False-position Method

• The bisection method divides the interval xl to xu in

half not accounting for the magnitudes of f(xl) and

f(xu). For example if f(xl) is closer to zero than f(xu),

then it is more likely that the root will be closer to

f(xl).

• False position method is an alternative approach

where f(xl) and f(xu) are joined by a straight line; the

intersection of which with the x-axis represents and

improved estimate of the root.

Page 22: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

2. False-position Method

• False position method is an

alternative approach where

f(xl) and f(xu) are joined by

a straight line; the

intersection of which with

the x-axis represents and

improved estimate of the

root.

Page 23: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

f(x)

x xu xl

f(xu)

f(xl)

xr

f(xr)

)()(

))((

)()(

ul

uluur

ur

u

lr

l

xfxf

xxxfxx

xx

xf

xx

xf

−−=

−=

False-position Method -Procedure

Page 24: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Step 1: Choose lower xl and upper xu guesses for the

root such that: f(xl).f(xu)<0

Step 2: The root estimate is:

Step 3: Subdivide the interval according to:

– If (f(xl).f(xr)<0) the root lies in the lower

subinterval; xu = xr and go to step 2.

– If (f(xl).f(xr)>0) the root lies in the upper

subinterval; xl = xr and go to step 2.

– If (f(xl).f(xr)=0) the root is xr and stop

)()(

))((

ul

uluur

xfxf

xxxfxx

−−=

False-position Method -Procedure

Page 25: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

False position method: Example

• The parachutist velocity is

• What is the drag coefficient c needed to reach a

velocity of 40 m/s if m =68.1 kg, t =10 s, g= 9.8 m/s2

f(c)

c

)(t

m

c

e1c

mgv

−=

40)1(38.667

)(

)1()(

146843.0−−=

−−=

c

tm

c

ec

cf

vec

mgcf

Page 26: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

f(x)

x 16 12

-2.269

6.067

14.91

False position method: Example

1. Assume xl = 12 and xu=16

f(xl)= 6.067 and f(xu)= -2.269

2. The root: xr=14.9113

f(12) . f(14.9113) = -1.5426 < 0;

3. The root lies bet. 12 and 14.9113.

4. Assume xl = 12 and xu=14.9113, f(xl)=6.067 and

f(xu)=-0.2543

5. The new root xr= 14.7942

6. This has an approximate error of 0.79%

Page 27: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

False position method: Example

Page 28: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Flow Chart –False Position Start

Input: xl , x0 , εs, maxi

f(xl). f(xu)<0

i=0

εa=1.1εs

False

while

εa> εs &

i <maxi

( )( )

( ) ( )

1

u l ur u

l u

f x x xx x

f x f x

i i

−= −

= +

False

Stop

Print: xr , f(xr ) ,εa , i

Page 29: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

i=1

or

xr=0

0 100%r r

a

r

x x

−=

True

Test=f(xl). f(xr)

εa=0.0 Test=0

xu=xr

xr0=xr

Test<0

xl=xr

xr0=xr

True

True

False

Page 30: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

False Position Method-Example 2

Page 31: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

False Position Method - Example 2

Page 32: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Pitfalls of the False Position Method

• Although a method such as false position is often superior to

bisection, there are some cases (when function has significant

curvature that violate this general conclusion.

• In such cases, the approximate error might be misleading and

the results should always be checked by substituting the root

estimate into the original equation and determining whether

the result is close to zero.

• major weakness of the false-position method: its one

sidedness That is, as iterations are proceeding, one of the

bracketing points will tend stay fixed which lead to poor

convergence.

Page 33: Numerical Analysis ECIV 3306 - libvolume3.xyzlibvolume3.xyz/.../developmentofalgorithmflowchartspresentation2.pdfNumerical Analysis ECIV 3306 Chapter 5 ... a r x x x ε − = True

Modified Fixed Position

• One way to mitigate the "one-sided" nature of

false position is to make the algorithm detect

when one of the bounds is stuck. If this occur,

the function value at the stagnant bound is

divided in half. This is thought to fasten the

convergence.