Computer Science/Numerical Methods/ Bisection method example

Computer Science/Numerical Methods/ Bisection method example

play-rounded-fill play-rounded-outline play-sharp-fill play-sharp-outline
pause-sharp-outline pause-sharp-fill pause-rounded-outline pause-rounded-fill
00:00

Bisection Method – Numerical Methods (Computer Science)

The Bisection Method is a root-finding technique that applies to continuous functions where the root lies between two given points. It is a simple and reliable method based on the Intermediate Value Theorem.



 Algorithm of Bisection Method

 Select two points a and b such that f(a)f(a) and f(b)f(b) have opposite signs (i.e., f(a)×f(b)<0f(a) \times f(b) < 0), ensuring a root exists in between.
 Compute the midpoint cc:

c=a+b2c = \frac{a + b}{2}

 Check f(c)f(c):

  • If f(c)=0f(c) = 0, then cc is the root.

  • If f(a)×f(c)<0f(a) \times f(c) < 0, then the root lies in [a, c], set b=cb = c.

  • Else, the root lies in [c, b], set a=ca = c.
     Repeat the process until the error tolerance is met:

∣b−a∣<tolerance|b – a| < \text{tolerance}

 Example: Find the root of f(x)=x3−x−2f(x) = x^3 – x – 2 in [1, 2]

Step 1: Check function values

f(1)=13−1−2=−2f(1) = 1^3 – 1 – 2 = -2
f(2)=23−2−2=4f(2) = 2^3 – 2 – 2 = 4
Since f(1)×f(2)<0f(1) \times f(2) < 0, a root exists between 1 and 2.

Step 2: Iterations

Iteration aa bb c=a+b2c = \frac{a+b}{2} f(c)f(c) Interval Change
1 1 2 1.5 -0.875 [1.5,2][1.5, 2]
2 1.5 2 1.75 1.609 [1.5,1.75][1.5, 1.75]
3 1.5 1.75 1.625 0.666 [1.5,1.625][1.5, 1.625]
4 1.5 1.625 1.5625 -0.271 [1.5625,1.625][1.5625, 1.625]
5 1.5625 1.625 1.5938 0.184 [1.5625,1.5938][1.5625, 1.5938]

The root is approximately 1.5938 with a small error.

Python Code for Bisection Method

def f(x):
return x**3 - x - 2 # Define the function
def bisection(a, b, tol=1e-6):
if f(a) * f(b) >= 0:
print(“Incorrect initial guesses.”)
return None

while abs(b – a) > tol:
c = (a + b) / 2
if f(c) == 0:
return c # Exact root found
elif f(a) * f(c) < 0:
b = c
else:
a = c
return (a + b) / 2

root = bisection(1, 2)
print(“Root is:”, root)

 Applications of Bisection Method

Solving non-linear equations in engineering & science
Finding zero crossings in signal processing
Used in numerical simulations & modeling

 Conclusion:

The Bisection Method is a simple, robust but slow root-finding method. It is best suited for cases where guaranteed convergence is needed.

Computer Science/Numerical Methods/ Bisection method example

Numerical Methods – Australian Mathematical Sciences Institute

Solutions of Equations in One Variable The Bisection Method

Solution of Algebraic and Transcendental Equations

Here’s a clear explanation of the Bisection Method with a complete example – ideal for students in Computer Science/Numerical Methods.


💻 Bisection Method – Numerical Methods in Computer Science

🧠 What is Bisection Method?

The Bisection Method is a numerical technique used to find roots of a continuous function f(x) within a given interval [a, b], where:

  • f(a) and f(b) have opposite signs (i.e., f(a) * f(b) < 0)

  • This implies a root exists between a and b (by Intermediate Value Theorem)


🔍 Step-by-Step Algorithm:

  1. Check that f(a) and f(b) have opposite signs.

  2. Calculate midpoint c = (a + b)/2.

  3. Check f(c):

    • If f(c) = 0, then c is the root.

    • Else, replace a or b with c based on sign change:

      • If f(a) * f(c) < 0, set b = c

      • Else, set a = c

  4. Repeat steps until desired accuracy is achieved (|f(c)| < ε, small error tolerance).


📘 Example: Find a root of f(x) = x³ – x – 2 using Bisection Method

Step 1: Choose initial interval [1, 2]

Check signs:

  • f(1) = 1³ – 1 – 2 = -2

  • f(2) = 8 – 2 – 2 = 4
    ✅ Opposite signs → root lies in [1, 2]

Step 2: Start Iteration

Iteration a b c = (a+b)/2 f(c) Interval
1 1.0 2.0 1.5 (1.5)³ – 1.5 – 2 = -0.125 [1.5, 2.0]
2 1.5 2.0 1.75 (1.75)³ – 1.75 – 2 = 1.609 [1.5, 1.75]
3 1.5 1.75 1.625 (1.625)³ – 1.625 – 2 ≈ 0.666 [1.5, 1.625]
4 1.5 1.625 1.5625 (1.5625)³ – 1.5625 – 2 ≈ 0.252 [1.5, 1.5625]
5 1.5 1.5625 1.53125 f(1.53125) ≈ 0.059

Repeat until |f(c)| < 0.001 or desired precision.


✅ Final Answer:

The root lies approximately near x ≈ 1.52 (can be refined with more iterations).


🧮 Use Cases in Computer Science:

  • Solving nonlinear equations in simulations

  • Numerical solvers in compilers and symbolic computation

  • Used in control systems, AI pathfinding (as a logic component)


Would you like:

  • A Python/C++ implementation of Bisection Method?

  • Practice problems with solutions?

  • A step-by-step worksheet for manual solving?

Let me know!

Computer Science/Numerical Methods/ Bisection method example

numerical methods



Leave a Reply

Your email address will not be published. Required fields are marked *

error: