numerical & statistical methods for computer engineering

35
G H PATEL COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY GUIDED BY: Prof. Krupal Parikh Preparad By: Pruthvi Bhagat (150113116001) Anu Bhatt (150113116002) Meet Mehta (150113116004) Hiral Patel (150113116005) Semester: 4 Subject : Numerical and Statistical Methods for Computer Engineering (2140706)

Upload: anu-bhatt

Post on 11-Apr-2017

285 views

Category:

Engineering


6 download

TRANSCRIPT

Page 1: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

G H PATEL COLLEGE OF ENGINEERING AND TECHNOLOGY

DEPARTMENT OF INFORMATION TECHNOLOGY

GUIDED BY: Prof. Krupal Parikh

Preparad By:Pruthvi Bhagat

(150113116001)Anu Bhatt

(150113116002)Meet Mehta

(150113116004)Hiral Patel

(150113116005)Janvi Patel

(150113116006)

Semester: 4Subject : Numerical and Statistical Methods for Computer

Engineering(2140706)

Page 2: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

BISECTION METHOD or BRACKETING METHOD

Page 3: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

WHAT IS BISECTION METHOD?

Bisection method is one of the closed methods (bracketing method) to determine the root of a nonlinear equation f(x) = 0, with the following main principles:

• Using two initial values to confine one or more roots of non-linear equations.

• Root value is estimated by the midpoint between two existing initial values.

Page 4: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

WHY BISECTION METHOD?• Bisection or Binary Search Method is based on

the intermediate value theorem.• It is a very simple and robust method to find the

roots of any given equation.• The method is guaranteed to converge to a root

of f, if f is a  continuous function on the interval [a, b] and f(a) and f(b) have opposite signs. The absolute error is halved at each step so the method converges linearly.

Page 5: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

THEOREM:

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

Page 6: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

ALGORTIHM FOR BISECTION METHOD:• Choose and as two guesses for the root such that

f() f()<0 and it is demonstrated in the figure below:

x

f(x)

xu x

Page 7: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

Estimate the root, of the equation f(x) = 0 as the mid point between as and as: =

x

f(x)

xu x

xm

Page 8: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

Now check the following: • If f()f()<0, then the root lies between and ; then

= ; = xm.

• If f()f()>0 , then the root lies between xm and ; then = ; = .

• If f()f()=0 ; then the root is . Stop the algorithm if this is true.

Page 9: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

GRAPHICAL REPRESENTATION

Page 10: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

EXAMPLE:

• Consider the following equation:

• Consider an initial interval of ylower = -10 to yupper = 10

• Since the signs are opposite, we know that the method will converge to a root of the equation.

Page 11: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..• The value of the function at the midpoint of the

interval is:

• The method can be better understood by looking at a graph of the function:

Page 12: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..

Page 13: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..• Now we eliminate half of the interval, keeping the

half where the sign of f(midpoint) is opposite the sign of f(endpoint).

• In this case, since f(ymid) = -6 and f(yupper) = 64, we keep the upper half of the interval, since the function crosses zero in this interval.

Page 14: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..• The interval has now been bisected, or halved:

Page 15: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..• New interval: ylower = 0, yupper = 10, ymid = 5• Function values:

Since f(ylower) and f(ymid) have opposite signs, the lower half of the interval is kept.

Page 16: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..• At each step, the difference between the high and

low values of y is compared to 2*(allowable error).

• If the difference is greater, than the procedure continues.

• Suppose we set the allowable error at 0.0005. As long as the width of the interval is greater than 0.001, we will continue to halve the interval.

• When the width is less than 0.001, then the midpoint of the range becomes our answer.

Page 17: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..ITERATION:

Initial Guesses

Is interval width narrow enough to stop?

Evaluate function at lower and mid values.

If signs are same (+ product), eliminate lower half of interval.

Page 18: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..NEXT ITERATION:

New Interval (if statements based on product at the end

of previous row)

Is interval width narrow enough to stop?

Evaluate function at lower and mid values.

If signs are different (- product), eliminate upper half of interval.

Page 19: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..• Continue until interval width < 2*error (here are

some of the 16 iterations).

Answer: y = 0.857

Page 20: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..• Of course, we know that the exact answer is 6/7

(0.857143).• If we want our answer accurate to 5 decimal

places, we could set the allowable error to 0.000005.

• This increases the number of iterations only from 16 to 22 – the halving process quickly reduces the interval to very small values.

• Even if the initial guesses are set to -10,000 and 10000, only 32 iterations are required to get a solution accurate to 5 decimal places.

Page 21: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONSIDER A POLYNOMIAL EXAMPLE:• Equation: f(x) = x2 - 2.• Start with an interval of length one: 

a0 = 1 and b1 = 2. Note that f (a0) = f(1) = - 1 < 0, f(b0) = f (2) = 2 > 0. Here are the first 20

iterations of the bisection method:

Page 22: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..

Page 23: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

Real life Application

Page 24: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

Example 1:

• You have a spherical storage tank containing oil. The tank has a diameter of 6 ft. You are asked to calculate the height to which a dipstick 8 ft long would be wet with oil when immersed in the tank when it contains 4 of oil.

Page 25: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..• The equation that gives the height, , of the liquid

in the spherical tank for the given volume and radius is given by

• Use the bisection method of finding roots of equations to find the height, to which the dipstick is wet with oil. 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.

08197.39 23 hhhf

Page 26: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..• Solution:• From the physics of the problem, the dipstick

would be wet between h=0 and h=2r , where r = radius of the tank, i.e.;

60)3(20

20

hh

rh

Page 27: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..• Let us assume,

• Check if the function changes sign between and .

• Hence ,

• So there is at least one root between & that is between 0 and 6.

6,0 uhh

8197.38197.30900)( 23 fhf

18.1048197.3)6(9)6()6() 23 ff(hu

018.1048197.360 ffhfhf u

Page 28: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..• Iteration 1:• The estimate of the root is

=3

Hence the root is bracketed between and , that is, between 0 and 3. So, the lower and upper limits of the new bracket are

2u

mhh

h

3

180.501897.33933 23 fhf m

0180.501897.330 ffhfhf m

3,0 uhh

Page 29: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..• At this point, the absolute relative approximate

error cannot be calculated, as we do not have a previous approximation.

• Root of f(x)=0 as a function of the number of iterations for bisection method.

Iteration h uh mh %a mhf 1 2 3 4 5 6 7 8 9 10

0.00 0.00 0.00 0.00

0.375 0.5625

0.65625 0.65625 0.65625 0.66797

6 3

1.5 0.75 0.75 0.75 0.75

0.70313 0.67969 0.67969

3 1.5

0.75 0.375

0.5625 0.65625 0.70313 0.67969 0.66797 0.67383

---------- 100 100 100

33.333 14.286 6.6667 3.4483 1.7544

0.86957

−50.180 −13.055

−0.82093 2.6068 1.1500

0.22635 −0.28215 −0.024077

0.10210 0.039249

Page 30: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..• At the end of the 10th iteration,

• Hence the number of significant digits at least correct is given by the largest value of m for which

%86957.0a

ma

2105.0

m 2107391.1 m27391.1log

759.17391.1log2 m

m 2105.086957.0

Page 31: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONTINUE..• The number of significant digits at least correct in

the estimated root 0.67383 is 2.

Page 32: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

ADVANTAGES OF BISECTION METHOD: • The bisection method is always convergent. Since

the method brackets the root, the method is guaranteed to converge.

• As iterations are conducted, the interval gets halved. So one can guarantee the error in the solution of the equation.

Page 33: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

DISADVANTAGES OF BISECTION METHOD:

• The convergence of the bisection method is slow as it is simply based on halving the interval.

• If one of the initial guesses is closer to the root, it will take larger number of iterations to reach the root.

• If f(x) is such that it just touches the x –axis, it will be unable to find the lower guess & upper guess.

Page 34: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

CONCLUSION:

Bisection method is the safest and it always converges. The bisection method is the simplest of all other methods and is guaranteed to converge for a continuous function.

It is always possible to find the number of steps required for a given accuracy and the new methods can also be developed from bisection method and bisection method plays a very crucial role in computer science research.

Page 35: NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING

THANK YOU