0% found this document useful (0 votes)
271 views

Bisection Method

The document describes the bisection method for finding the root of a continuous function f(x) = 0 within a given interval [a,b]. It explains that the method repeatedly bisects the interval in half and evaluates f(x) at the midpoint c to determine if a root exists in the lower or upper half. If f(a) and f(c) have opposite signs, the root must be in [a,c], otherwise it is in [c,b]. This process continues until the interval width is smaller than a specified tolerance. Pseudocode and a flowchart provide examples of the iterative bisection algorithm.

Uploaded by

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

Bisection Method

The document describes the bisection method for finding the root of a continuous function f(x) = 0 within a given interval [a,b]. It explains that the method repeatedly bisects the interval in half and evaluates f(x) at the midpoint c to determine if a root exists in the lower or upper half. If f(a) and f(c) have opposite signs, the root must be in [a,c], otherwise it is in [c,b]. This process continues until the interval width is smaller than a specified tolerance. Pseudocode and a flowchart provide examples of the iterative bisection algorithm.

Uploaded by

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

BFC 20802

COMPUTER PROGRAMMING

INDIVIDUAL ASSIGNMENT

NAME : MUHAMMAD FAIZ BIN ABDUL HADI

MATRIC NO. : CF150174

SECTION : 8

LECTURERS NAME : DR MUHAMMAD NIZAM BIN ZAKARIA


INTRODUCTION

The bisection method in mathematics is a root-finding method that repeatedly bisects an interval
and then selects a subinterval in which a root must lie for further processing. It is very simple
and robust method, but it is also relatively slow. Because of this, it is often used to obtain a rough
approximation to a solution which is then used as a straight point for more rapidly converging
methods. The method is also called the interval halving method, the binary search method or the
dichotomy method.

The Method

The method is applicable for numerically solving the equation f(x) = 0 for the real variable x,
where f is a continuous function defined on an interval [a, b] and where f(a) and f(b) have
opposite signs. In this case a and b are said to bracket a root since, by the intermediate value
theorem, the continuous function f must have at least one root in the interval (a, b).

At each step the method divides the interval in two by computing the midpoint c = (a+b) / 2 of
the interval and the value of the function f(c) at that point. Unless c is itself a root (which is very
unlikely, but possible) there are now only two possibilities: either f(a) and f(c) have opposite
signs and bracket a root, or f(c) and f(b) have opposite signs and bracket a root. The method
selects the subinterval that is guaranteed to be a bracket as the new interval to be used in the next
step. In this way an interval that contains a zero of f is reduced in width by 50% at each step. The
process is continued until the interval is sufficiently small.

Explicitly, if f(a) and f(c) have opposite signs, then the method sets c as the new value for b, and
if f(b) and f(c) have opposite signs then the method sets c as the new a. (If f(c)=0 then c may be
taken as the solution and the process stops.) In both cases, the new f(a) and f(b) have opposite
signs, so the method is applicable to this smaller interval.
Iteration tasks

The input for the method is a continuous function f, an interval [a, b], and the function
values f(a) and f(b). The function values are of opposite sign (there is at least one zero crossing
within the interval). Each iteration performs these steps:

1. Calculate c, the midpoint of the interval, c = 0.5 * (a + b).


2. Calculate the function value at the midpoint, f(c).
3. If convergence is satisfactory (that is, a - c is sufficiently small, or f(c) is sufficiently
small), return c and stop iterating.
4. Examine the sign of f(c) and replace either (a, f(a)) or (b, f(b)) with (c, f(c)) so that there
is a zero crossing within the new interval.

When implementing the method on a computer, there can be problems with finite precision, so
there are often additional convergence tests or limits to the number of iterations. Although f is
continuous, finite precision may preclude a function value ever being zero. For f(x) = x , there
will never be a finite representation of x that gives zero. Floating point representations also have
limited precision, so at some point the midpoint of [a, b] will be either a or b.

Example : A few step of the bisection method applied over the starting range ( a1,b1 ) the
bigger red dot is the root of the function.
PSEUODOCODE

1. INPUT: Function f, endpoint values a, b, tolerance TOL, maximum iterations NMAX


2. CONDITIONS: a < b, either f(a) < 0 and f(b) > 0 or f(a) > 0 and f(b) < 0
3. OUTPUT: value which differs from a root of f(x)=0 by less than TOL
4. N 1
5. While N NMAX # limit iterations to prevent infinite loop
6. c (a + b)/2 # new midpoint
7. If f(c) = 0 or (b a)/2 < TOL then # solution found
8. Output(c)
9. Stop
10. EndI
11. N N + 1 # increment step counter
12. If sign(f(c)) = sign(f(a)) then a c else b c # new interval
13. End While
14. Output("Method failed.") # max number of steps exceeded
Flow Chart
C++ PROGRAMMING

Output
Input

You might also like