Bisection Method
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.
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
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
n 𝒂𝒏 𝒃𝒏 𝒑𝒏 𝒇(𝒑𝒏 )
1 0 1 0.5 -0.625
n 𝒂𝒏 𝒃𝒏 𝒑𝒏 𝒇(𝒑𝒏 )
1 0 1 0.5 -0.2071
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