1/29/2016 1 bisection method computer engineering majors authors: autar kaw, jai paul

27
06/13/22 http:// numericalmethods.eng.usf.edu 1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul http://numericalmethods.eng.u sf.edu Transforming Numerical Methods Education for STEM Undergraduates

Upload: jeremy-fleming

Post on 17-Jan-2018

254 views

Category:

Documents


0 download

DESCRIPTION

3 Basis of Bisection Method Theorem An equation f(x)=0, where f(x) is a real continuous function, has at least one root between x l and x u if f(x l ) f(x u ) < 0. Figure 1 At least one root exists between the two points if the function is real, continuous, and changes sign.

TRANSCRIPT

Page 1: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

05/03/23http://

numericalmethods.eng.usf.edu 1

Bisection Method

Computer Engineering Majors

Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.eduTransforming Numerical Methods Education for STEM

Undergraduates

Page 2: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

Bisection Method

http://numericalmethods.eng.usf.edu

Page 3: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu3

Basis of Bisection MethodTheorem

x

f(x)

xu x

An equation f(x)=0, where f(x) is a real continuous function, has at least one root between xl and xu if f(xl) f(xu) < 0.

Figure 1 At least one root exists between the two points if the function is real, continuous, and changes sign.

Page 4: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

x

f(x)

xu x

http://numericalmethods.eng.usf.edu4

Basis of Bisection Method

Figure 2 If function does not change sign between two points, roots of the equation may still exist between the two points.

xf 0xf

Page 5: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

x

f(x)

xu x

http://numericalmethods.eng.usf.edu5

Basis of Bisection Method

Figure 3 If the function does not change sign between two points, there may not be any roots for the equation between the two points.

x

f(x)

xu x

xf 0xf

Page 6: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

x

f(x)

xu x

http://numericalmethods.eng.usf.edu6

Basis of Bisection Method

Figure 4 If the function changes sign between two points, more than one root for the equation may exist

between the two points.

xf 0xf

Page 7: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu7

Algorithm for Bisection Method

Page 8: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu8

Step 1Choose x and xu as two guesses for the root such that f(x) f(xu) < 0, or in other words, f(x) changes sign between x and xu. This was demonstrated in Figure 1.

x

f(x)

xu x

Figure 1

Page 9: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

x

f(x)

xu x

xm

http://numericalmethods.eng.usf.edu9

Step 2Estimate the root, xm of the equation f (x) = 0 as the mid point between x and xu as

xx

m = xu

2

Figure 5 Estimate of xm

Page 10: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu10

Step 3Now check the following

a) If , then the root lies between x and xm; then x = x ; xu = xm.

b) If , then the root lies between xm and xu; then x = xm; xu = xu.

c) If ; then the root is xm. Stop the algorithm if this is true.

0ml xfxf

0ml xfxf

0ml xfxf

Page 11: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu11

Step 4

xx

m = x u

2

100

newm

oldm

new

a xxx

m

root of estimatecurrent newmx

root of estimate previousoldmx

Find the new estimate of the root

Find the absolute relative approximate error

where

Page 12: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu12

Step 5

Is ?

Yes

No

Go to Step 2 using new upper and lower

guesses.

Stop the algorithm

Compare the absolute relative approximate error with the pre-specified error tolerance .

as

sa

Note one should also check whether the number of iterations is more than the maximum number of iterations allowed. If so, one needs to terminate the algorithm and notify the user about it.

Page 13: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu13

Example 1To find the inverse of a value, a, one can use the equation

where x is the inverse of a.

Use the bisection method of finding roots of equations to find the inverse of a = 2.5. Conduct three iterations to estimate the root of the above equation.

Find the absolute relative approximate error at the end of each iteration and the number of significant digits at least correct at the end of each iteration.

01x

axf

Page 14: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu14

Example 1 Cont.

Figure 8 Graph of the function f(x).

01x

axf

0 0.25 0.5 0.75 11

0.5

0

0.5

1

1.5

f(x)

1.5

1

0f x( )

10 x

Page 15: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

1 0.5 0 0.5 1 1.54

3

2

1

0

1

2

f(x)xu (upper guess)xl (lower guess)

1.505

3.5

0

f x( )

f x( )

f x( )

1.0021 x x u x l

Entered function on given interval with initial upper and lower guesses

Figure 9 Checking that the bracket is valid.

http://numericalmethods.eng.usf.edu15

Example 1 Cont.Solutio

n

Let us assume015.2)(

01)(

01

xxfaxxf

xa

1 ,0 ul xx

Check if the function changes sign between and .

lx ux 5.1115.21

1105.20

fxffxf

u

l

There is at least one root between the brackets.

05.1110 ffxfxf ul

Page 16: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu16

Example 1 Cont.Iteration 1The estimate of the root is

5.02

102

ulm

xxx

025.015.00

25.015.05.25.0

ffxfxf

fxf

ml

m

The root is bracketed between and . The lower and upper limits of the new bracket are 5.0 ,0 ul xxThe absolute relative approximate error cannot be calculated as we do not have a previous approximation.

mxlx

aFigure 10 Graph of the estimated root after Iteration 1.

1 0.5 0 0.5 1 1.54

3

2

1

0

1

2

f(x)xu (upper guess)xl (lower guess)new guess

1.505

3.5

0f x( )

f x( )

f x( )

f x( )

1.0021 x x u x l x r

Page 17: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu17

Example 1 Cont.Iteration 2The estimate of the root

is25.0

25.00

2

ul

mxxx

375.0125.05.225.0 fxf m

The root is bracketed between and . The lower and upper limits of the new bracket are

5.0 x,25.0 ulx

uxmx

Figure 11 Graph of the estimated root after Iteration 2.

1 0.5 0 0.5 1 1.54

3

2

1

0

1

2

f(x)xu (upper guess)xl (lower guess)new guess

1.505

3.5

0f x( )

f x( )

f x( )

f x( )

1.0021 x x u x l x r

025.0375.0

5.025.0

ffxfxf um

Page 18: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu18

Example 1 Cont.

%100

10025.0

5.025.0

100

newm

oldm

newm

a xxx

None of the significant digits are at least correct in the estimated root of

as the absolute relative approximate error is greater than 5%.

25.0mx

The absolute relative approximate error at the end of Iteration 2 is

a

Page 19: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu19

Example 1 Cont.Iteration 3The estimate of the

root is375.0

25.025.0

2

ul

mxxx

0625.01375.05.2375.0 fxf m

The root is bracketed between and .

5.0 ,25.0 ul xx

uxmx

025.00625.0

5.0375.0

ffxfxf um

Figure 12 Graph of the estimated root after Iteration 3.

1 0.5 0 0.5 1 1.54

3

2

1

0

1

2

f(x)xu (upper guess)xl (lower guess)new guess

1.505

3.5

0f x( )

f x( )

f x( )

f x( )

1.0021 x x u x l x r

The lower and upper limits of the new bracket are

Page 20: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu20

Example 1 Cont.

%333.33

100375.0

25.0375.0

100

newm

oldm

newm

a xxx

Still none of the significant digits are at least correct in the estimated root of the equation as the absolute relative approximate error is greater than 5%. Seven more iterations were conducted and these iterations are shown in the table below.

The absolute relative approximate error at the end of Iteration 3 is

a

Page 21: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

Iteration xl xu xm12345678910

000.250.3750.3750.3750.390630.398440.398440.39844

10.50.50.50.43750.406250.406250.406250.402340.40039

0.50.250.3750.43750.406250.390630.398440.402340.400390.39941

----------10033.3314.28577.69234.001.96080.970870.487800.24450

0.25−0.375−0.0625 0.09375 0.01563−0.02344−3.90625×10-3

5.8594×10-3

9.7656×10-4

−1.4648×10-3

http://numericalmethods.eng.usf.edu21

Example 1 Cont.Table 1 Root of as function of number of iterations for bisection method.

%a

0xf

mxf

Page 22: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu22

Advantages Always convergent The root bracket gets halved with

each iteration - guaranteed.

Page 23: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu23

Drawbacks Slow convergence If one of the initial guesses is close

to the root, the convergence is slower

Page 24: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu24

Drawbacks (continued) If a function f(x) is such that it just

touches the x-axis it will be unable to find the lower and upper guesses.

f(x)

x

2xxf

Page 25: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu25

Drawbacks (continued) Function changes sign but root does

not exist

f(x)

x

x

xf 1

Page 26: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

Additional ResourcesFor all resources on this topic such as digital audiovisual lectures, primers, textbook chapters, multiple-choice tests, worksheets in MATLAB, MATHEMATICA, MathCad and MAPLE, blogs, related physical problems, please visit

http://numericalmethods.eng.usf.edu/topics/bisection_method.html

Page 27: 1/29/2016  1 Bisection Method Computer Engineering Majors Authors: Autar Kaw, Jai Paul

THE END

http://numericalmethods.eng.usf.edu