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

Bisection Method

Uploaded by

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

Bisection Method

Uploaded by

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

Bisection Method

The Bisection Method is a simple and reliable numerical technique used to find the
solution to equations. In essence, it's like "guessing" where the answer might be,
but each guess gets you closer to the correct result by cutting the range in half
repeatedly until you get close enough.

How It Works

• Imagine you have a function, and you're trying to find the point where it
crosses the x-axis (the point where the output value is zero). The Bisection
Method works by taking two guesses, one on each side of the solution
(meaning one where the function gives a positive value and one where it gives
a negative value), and then it keeps cutting the range in half until the correct
answer is found.

In computer graphics,
especially in ray tracing, the
Bisection Method can be used
to find intersections between
light rays and surfaces. If the
equation defining a surface is
too complex to solve
analytically, the Bisection
Method can be used to
iteratively find where a ray
hits the surface by narrowing
down where the equation
changes sign, helping with
shadows, reflections, and
lighting effects.
Example in Real Life: Finding a Broken Network Cable

• Let’s say you’re trying to find where a network cable is broken. The
cable runs between two servers, and somewhere in the middle,
there's a fault, but you don’t know exactly where. Here’s how the
Bisection Method could help you:

Step 1 – Start with Step 2 – Test the Step 3 – Narrow Step 4 – Find the
Two Guesses: Middle: the Range: Break:

• - You know the • - You pick a point • - You now repeat • - After several
cable works at halfway between this process: steps, you will
Server A (the the two servers testing the have a small
starting point), and and test the cable midpoint of the enough range that
you know it’s not there. faulty half of the you know exactly
working at Server • - If the cable cable, narrowing where the break is
B (the endpoint). works at this down the location located. This is
These are like the midpoint, you of the break each how the Bisection
two points that the know the problem time by cutting the Method works—it
Bisection Method is in the second range in half. narrows down the
starts with. half of the cable, • - Each step gets solution range by
closer to Server B. you closer to the repeatedly cutting
• - If the cable exact location of the interval in half.
doesn’t work, you the fault.
know the problem
is in the first half,
closer to Server A.
The Bisection Method is like playing a game of hot-and-cold with
math. You know the answer lies somewhere between two points, and
by cutting the interval in half each time, you can quickly home in on
the solution. Whether you're finding a broken cable or calculating
light effects in a game, this simple but powerful technique helps you
solve problems more efficiently.

SOLUTIONS OF EQUATIONS IN ONE VARIABLE


We consider one of the most basic problems of numerical approximation, the root-
finding problem. This process involves finding a root, or solution, of an equation
of the form f (x) = 0, for a given function f.
We can solve equations:
𝑥 3 + 4𝑥 2 − 10 = 0 on the interval [1, 2] ,
𝑥 cos 𝑥 − 2𝑥 2 + 3𝑥 − 1 = 0 on the interval [1.2, 1.3] ,
(𝑥 − 2)2 − ln 𝑥 = 0 on the intervals [1, 2] and [e, 4].

MATHEMATICAL AND GRAPHICAL REPRESENTATION

The first technique to solve equations like above, based on the Intermediate Value
Theorem, is called the Bisection, or Binary-search, method.
Suppose f(x)=0 is a continuous function defined on [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.
The bisection method calls for 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, 𝑝1 =
2

Let 𝑓(𝑎1) and 𝑓(𝑝1) have different signs but 𝑓(𝑝1) and 𝑓(𝑏1) have same signs, then
𝑎 +𝑏
the root lies in the interval [𝑎1, 𝑝1]. Set 𝑎1 = 𝑎2 and 𝑝1 = 𝑏2, and let 𝑝2 = 2 2
2

If 𝑓(𝑎2) and 𝑓(𝑝2) have same signs but 𝑓(𝑝2) and 𝑓(𝑏2) have different signs, then
𝑎 +𝑏
the root lies in the interval [𝑝2, b2]. Then find 𝑝3 = 3 3 on the same lines
2

Determining the successive values of 𝑝4 , 𝑝5 , 𝑝6 , … there exists 𝑝𝑛 for some n such


that 𝑓(𝑝𝑛 ) is very close to 0. Such 𝑝𝑛 will be required root of the equation 𝑓(𝑥) = 0.

Example 1
If we have an equation in the form 𝑐𝑜𝑠(𝑡) = 3𝑡 − 1, put it equal to 0, that is
𝑓(𝑡) = cos(𝑡) − 3𝑡 + 1 = 0.
Find the interval [a, 𝑏] as [0, 1] of solution for 𝑓(𝑡) = cos(𝑡) − 3𝑡 + 1
with 𝑓(0) = 2 > 0 and 𝑓(1) = −1.46 < 0, then use
𝑎+𝑏
𝑝𝑖 = , 𝑖 = 0,1,2, …
2
First Iteration 𝒑𝟏 : First find
𝑎+𝑏 0+1
𝑝1 = = = 0.5
2 2
Now we will substitute 𝑝1 = 0.5, in 𝑓(𝑡), and we have
𝑓(0.5) = cos(0.5) − 3(0.5) + 1 = 0.3776 > 0
As we know that 𝑓(0) > 0, like 𝑓(0.5) so we will replace 0.5 by 0 in the interval.
We have the new interval as [0.5, 1] and it completes First Iteration.
Second Iteration 𝒊 = 𝟐:
𝑎 + 𝑏 0.5 + 1
𝑝2 = = = 0.75
2 2
We will substitute 𝑝2 = 0.75, in 𝑓(𝑡), implies
𝑓(0.75) = cos(0.75) − 3(0.75) + 1 = −0.5183 < 0
As we know at 𝑡 = 1, 𝑓(𝑡) < 0, so we will replace 0.75 by 1 in the interval and
we have new interval [0.5,0.75]. It completes second Iteration.
In this way we will proceed further to find 𝑝3 , 𝑝4 , 𝑝5 , …
until the gap between two 𝑝𝑖 is very less (say within 10−3 )
|𝑏 − 𝑎| < 10−3 (= 0.001)
or any other given criteria like
(i) |𝑝𝑖 − 𝑝𝑖−1 | < 𝜀 or (ii) |𝑓(𝑝𝑛 )| < 𝜀,
As we get 𝑝3 , 𝑝4 , 𝑝5 , 𝑝6 , … 𝑝12 = 0.625, 0.5625, 0.59375, 0.6094, . . . , 0.6072
with 𝑓(𝑝12 ) = −0.00035 with required accuracy as the solution.

Example 2
Use bisection method to find solution accurate to within 10−2 for
𝑥 3 − 7𝑥 2 + 14𝑥 − 6 = 0 on the interval [0, 1] .
Solution
Let us mark 𝑎 = 0 and b = 1, and for 𝑓(𝑥) = 𝑥 3 − 7𝑥 2 + 14𝑥 − 6, we know that
𝑓(0) = −6 < 0 and 𝑓(1) = 2 > 0.
𝑎+𝑏 0+1
So for the first iteration: 𝑝1 = = = 0.5, with
2 2

𝑓(0.5) = −0.625 < 0


As at 𝑥 = 0, 𝑓(𝑥) < 0, so we will replace 0 with 0.5 in the interval. So we have
new interval [0.5, 1] completing the First Iteration.
𝑎+𝑏 0.5+1
Second Iteration: 𝑝2 = = = 0.75
2 2

Now we will substitute 𝑝2 = 0.75, in 𝐹(𝑥), we have


𝑓(0.75) = 0.9844 > 0
As we know at 𝑥 = 1, 𝑓(𝑥) > 0, so we will put 0.75 in place of 1 in the interval.
We can summarize these iterations in the form of a table as:

n 𝒂𝒏 𝒃𝒏 𝒑𝒏 𝒇(𝒑𝒏 )

1 0 1 0.5 -0.625

2 0.5 1 0.75 0.9844

3 0.5 0.75 0.625 0.2598

4 0.5 0.625 0.5625 -0.1619

5 0.5625 0.625 0.5938 0.0544

6 0.5625 0.5938 0.5782 -0.0521

7 0.5782 0.5938 0.5860 0.0015

8 0.5782 0.5860 0.5821 -0.025

9 0.5821 0.5860 0.5841 -0.0115

Since, 𝐸𝑅𝑅𝑂𝑅 = |𝑝9 − 𝑝8 | = 0.002, So the approximated solution is 𝑥 = 0.58.


PROBLEM STATEMENT
Imagine you are working as a software developer tasked with optimizing a
computer network. The system’s performance is heavily dependent on balancing
network traffic to avoid bottlenecks. To model the traffic, a nonlinear equation
such as 𝑥 − 2−𝑥 = 0 can represent how traffic flow decreases exponentially based
on certain conditions (like increasing congestion). You need to find the exact
balance point of traffic, where the system stabilizes. Using the Bisection Method,
you can accurately calculate this balance point within the interval [0, 1], helping
ensure that your network operates efficiently and without congestion. Let’s find the
solution to this equation, accurate to within 10−5 , so you can apply it to your
traffic management system.
Solution
Let us mark 𝑎 = 0 and b = 1, and for
𝑓(𝑥) = 𝑥 − 2−𝑥 , 𝑓(0) = −1 < 0 and 𝑓(1) = 0.5 > 0.

n 𝒂𝒏 𝒃𝒏 𝒑𝒏 𝒇(𝒑𝒏 )

1 0 1 0.5 -0.2071

2 0.5 1 0.75 0.1554

3 0.5 0.75 0.625 -0.0234

4 0.625 0.75 0.6875 0.0666

5 0.625 0.6875 0.65625 0.02172

6 0.625 0.65625 0.640625 -0.00081

7 0.640625 0.65625 0.64844 0.0105

8 0.640625 0.64844 0.64453 0.005

9 0.640625 0.64453 0.64258 0.002


10 0.640625 0.64258 0.64160 0.0006

11 0.640625 0.64160 0.64111 -0.00011

12 0.64111 0.64160 0.641355 0.000245

13 0.64111 0.641355 0.64123 0.00006

14 0.64111 0.64123 0.64117 -0.000023

15 0.64117 0.64123 0.64120 0.00002

So the approximated solution is 𝑥 = 0.64120.

Python Code
Results

Disadvantage Advantage
The Bisection method, though conceptually The method has the important
clear, has significant drawbacks. It is property that it always converges
relatively slow to converge (that is, N may to a solution.
become quite large before | 𝑝 − 𝑝𝑁 | is
sufficiently small), and a good intermediate
approximation might be inadvertently
discarded.
PRACTICE

You might also like