DIZNR INTERNATIONAL

Computer Science/Numerical Methods/ Bisection method example

Computer Science/Numerical Methods/ Bisection method example

https://www.gyanodhan.com/video/7A2.%20Computer%20Science/Numerical%20Methods/679.%20Bisection%20method%20example.mp4

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):

∣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 Nonewhile 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) / 2root = 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:


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:

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:


Would you like:

Let me know!

Computer Science/Numerical Methods/ Bisection method example

numerical methods