Computer Science/Numerical Methods/ Bisection method example
Computer Science/Numerical Methods/ Bisection method example
Contents [hide]
- 0.1 Bisection Method – Numerical Methods (Computer Science)
- 0.2 Algorithm of Bisection Method
- 0.3 Example: Find the root of f(x)=x3−x−2f(x) = x^3 – x – 2f(x)=x3−x−2 in [1, 2]
- 0.4 Step 1: Check function values
- 0.5 Step 2: Iterations
- 0.6 Python Code for Bisection Method
- 0.7 Applications of Bisection Method
- 0.8 Conclusion:
- 0.9 Computer Science/Numerical Methods/ Bisection method example
- 0.10 Numerical Methods – Australian Mathematical Sciences Institute
- 0.11 Solutions of Equations in One Variable The Bisection Method
- 0.12 Solution of Algebraic and Transcendental Equations
- 1
Bisection Method – Numerical Methods in Computer Science
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
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)
andf(b)
have opposite signs (i.e.,f(a) * f(b) < 0
) -
This implies a root exists between
a
andb
(by Intermediate Value Theorem)
Step-by-Step Algorithm:
-
Check that
f(a)
andf(b)
have opposite signs. -
Calculate midpoint
c = (a + b)/2
. -
Check
f(c)
:-
If
f(c) = 0
, thenc
is the root. -
Else, replace
a
orb
withc
based on sign change:-
If
f(a) * f(c) < 0
, setb = c
-
Else, set
a = c
-
-
-
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!