Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
30 views

Week 02 - Lecture Notes

Uploaded by

2312233
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Week 02 - Lecture Notes

Uploaded by

2312233
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Numerical Computing

Week 02

by
Dr. Sajjad A. Ghauri
Bisection Method

ˆ How to solve algebraic and transcendental equations.

ˆ How to find roots of these equations.

ˆ This method is based on the repeated application of intermediate value property.

The first technique, based on the Intermediate Value Theorem, is called the Bisection, or
Binary-search, method.

Suppose f (x) is a continuous function defined on the interval [a, b], with f (a) and f (b) of
opposite sign. The Intermediate Value Theorem implies that a number p exists in (a, b) with
f (p) = 0. Although the procedure will work when there is more than one root in the interval
(a, b), we assume for simplicity that the root in this interval is unique. The method calls for
a repeated halving (or bisecting) of subintervals of [a, b] and, at each step, locating the half
containing p. To begin, set a1 = a and b1 = b, and let p1 be the midpoint of [a, b], that is,

b 1 − a1 a1 + b 1
p 1 = a1 + = .
2 2

ˆ If f (p1 ) = 0, then p = p1 , and we are done.

ˆ If f (p1 ) ̸= 0, then f (p1 ) has the same sign as either f (a1 ) or f (b1 ).

ˆ If f (p1 ) and f (a1 ) have the same sign, p ∈ (p1 , b1 ). Set a2 = p1 and b2 = b1 .

ˆ If f (p1 ) and f (a1 ) have opposite signs, p ∈ (a1 , p1 ). Set a2 = a1 and b2 = p1 .

ˆ This process is repeated with new points until root is determined sufficient accuracy.

1
Example 1: Find the root of the following equation by bisection method.

x3 − x − 1 =0,

Here f (x) = x3 − x − 1.

f (0) =03 − 0 − 1 = −1,

f (1) =13 − 1 − 1 = −1,

f (2) =23 − 2 − 1 = 5,

1st iteration: Here f (1) = −1 < 0 and f (2) = 5 > 0. Now, Root lies between 1 and 2.
1+2
x0 =
2
x0 =1.5

f (x0 ) =f (1.5) = 1.53 − 1.5 − 1 = 0.875 > 0

2nd iteration: Here f (1) = −1 < 0 and f (1.5) = 0.875 > 0. Now, Root lies between 1 and
1.5
1 + 1.5
x1 =
2
x1 =1.25

f (x1 ) =f (1.25) = 1.253 − 1.25 − 1 = −0.2969 < 0

3rd iteration: Here f (1.25) = −0.2969 < 0 and f (1.5) = 0.875 > 0. Now, Root lies
between 1.25 and 1.5
1.25 + 1.5
x2 =
2
x2 =1.375

f (x2 ) =f (1.375) = 1.3753 − 1.375 − 1 = 0.2246 > 0

Similarly, we have

2
a+b
n a f (a) b f (b) c= 2
f (c) Update
1 1 -1 2 5 1.5 0.875 b=c
2 1 -1 1.5 0.875 1.25 -0.2969 a=c
3 1.25 -0.2969 1.5 0.875 1.375 0.2246 b=c
4 1.25 -0.2969 1.375 0.2246 1.3125 -0.0515 a=c
5 1.3125 -0.0515 1.375 0.2246 1.3438 0.0826 b=c
6 1.3125 -0.0515 1.3438 0.0826 1.3281 0.0146 b=c
7 1.3125 -0.0515 1.3281 0.0146 1.3203 -0.0187 a=c
8 1.3203 -0.0187 1.3281 0.0146 1.3242 -0.0021 a=c
9 1.3242 -0.0021 1.3281 0.0146 1.3262 0.0062 b=c
10 1.3242 -0.0021 1.3262 0.0062 1.3252 0.002 b=c
11 1.3242 -0.0021 1.3252 0.002 1.3247 0 a=c

Approximate root of the equation x3 − x − 1 = 0 using Bisection method is 1.3247 (correct


to 4 dp) (After 11 iterations).

Example 2: Find the root of the following equation by bisection method between [1, 2].
x
sin x − =0,
2

Here f (x) = sin x − x2 .

1st iteration: Here f (1) = 0.3415 > 0 and f (2) = −0.0907 < 0. Now, Root lies between 1
and 2.

1+2
x0 =
2
x0 =1.5
1.5
f (x0 ) =f (1.5) = sin(1.5) − = 0.2475 > 0
2

2nd iteration: Here f (1.5) = 0.2475 > 0 and f (2) = −0.0907 < 0. Now, Root lies between

3
1.5 and 2
1.5 + 2
x1 =
2
x1 =1.75

f (x1 ) =f (1.25) = 0.109 > 0

3rd iteration: Here f (1.75) = 0.109 > 0 and f (2) = −0.0907 < 0. Now, Root lies between
1.75 and 2
1.75 + 2
x2 =
2
x2 =1.875

f (x2 ) =f (1.875) = 0.0166 > 0

Similarly, we have
a+b
n a f (a) b f (b) c= 2
f (c) Update
1 1 0.3415 2 -0.0907 1.5 0.2475 a=c
2 1.5 0.2475 2 -0.0907 1.75 0.109 a=c
3 1.75 0.109 2 -0.0907 1.875 0.0166 a=c
4 1.875 0.0166 2 -0.0907 1.9375 -0.0352 b=c
5 1.875 0.0166 1.9375 -0.0352 1.9062 -0.0089 b=c
6 1.875 0.0166 1.9062 -0.0089 1.8906 0.004 a=c
7 1.8906 0.004 1.9062 -0.0089 1.8984 -0.0024 b=c
8 1.8906 0.004 1.8984 -0.0024 1.8945 0.0008 a=c
9 1.8945 0.0008 1.8984 -0.0024 1.8965 -0.0008 b=c
10 1.8945 0.0008 1.8965 -0.0008 1.8955 0 b=c
Approximate root of the equation sin x − x2 = 0 using Bisection method is 1.8955 (correct to
4 dp) (After 10 iterations).

Exercise 1: Find the root of the following equation by bisection method correct to four
dp upto four stages.

x3 − 4x − 9 =0,

4
Exercise 2: Find the root of the following equation by bisection method correct to three
dp upto five stages.

x4 − 2x3 − 4x2 + 4x + 4 =0, x ∈ [0, 2]

Bisection Method: The bisection Method is one of the simplest, most reliable, easy
to implement, and convergence-guaranteed methods for finding the real root of non-linear
equations. It is also known as Binary Search or Half Interval or Bolzano Method.

The bisection method is a bracketing method and starts with two initial guesses say x0 and
x1 such that x0 and x1 brackets the root i.e., f (x0 )f (x1 ) < 0.

The bisection method is based on the fact that if f (x) is a real and continuous function,
and for two initial guesses x0 and x1 brackets the root such that, f (x0 )f (x1 ) < 0 then there
exists at least one root between x0 and x1 . The root is obtained in the Bisection method by
successive halving the interval i.e. If x0 and x1 are two guesses, then we compute the new
x0 +x1
approximated root as, x2 = 2
. Now we have the following three different cases,

ˆ If f (x2 ) = 0 then the root is x2 .

ˆ If f (x0 )f (x2 ) < 0 then the root lies between x0 and x2 .

ˆ If f (x0 )f (x2 ) > 0 then root lies between x1 and x2 .

And then the process is repeated until we find the root within the desired accuracy.

Bisection Method Algorithm (Step Wise):

1. Start

2. Define function f (x)

3. Choose initial guesses x0 and x1 such that f (x0 )f (x1 ) < 0

4. Choose pre-specified tolerable error e.

x0 +x1
5. Calculate new approximated root as x2 = 2

5
6. Calculate f (x0 )f (x2 )

a. if f (x0 )f (x2 ) < 0 then x0 = x0 and x1 = x2

b. if f (x0 )f (x2 ) > 0 then x0 = x2 and x1 = x1

c. if f (x0 )f (x2 ) = 0 then goto (8)

7. if |f (x2 )| > e then goto (5) otherwise goto (8)

8. Display x2 as root.

9. Stop

In Numerical analysis (methods), Bisection method is one of the simplest, convergence guar-
anteed method to find real root of non-linear equations.

Merits of Bisection Method: Bisection method also known as Bolzano or Half


Interval, or Binary Search method has the following merits or benefits.

1. Convergence is guaranteed: The bisection method is a bracketing method and it is


always convergent.

2. Error can be controlled: In the Bisection method, an increasing number of iterations


always yields a more accurate root.

3. Does not involve complex calculations: The bisection method does not require any
complex calculations. To perform the Bisection method, all we need is to calculate the
average of two numbers.

4. Guaranteed error bound: In this method, there is a guaranteed error bound, and it
1
decreases with each successive iteration. The error bound decreases by 2
with each
iteration.

5. Bisection method is very simple and easy to program on the computer.

6. Bisection method is fast in case of multiple roots.

6
Demerits of Bisection Method: In Numerical analysis (methods), the Bisection
method has a slow rate of convergence. The bisection method has the following demerits.

1. Slow Rate of Convergence: Although the convergence of the Bisection method is guar-
anteed, it is generally slow.

2. Choosing one guess close to the root has no advantage: Choosing one guess close to
the root may result in requiring many iterations to converge.

3. Cannot find the root of some equations. For example: f (x) = x2 as there are no
bracketing values.

4. It has a linear rate of convergence.

5. It fails to determine complex roots.

6. It cannot be applied if there are discontinuities in the guess interval.

7. It cannot be applied over an interval where the function takes values of the same sign.

You might also like