Experiment No4
Experiment No4
Theory: The bisection method is a simple and reliable numerical technique used to find the
roots of a continuous function. It works by repeatedly narrowing down an interval [a, b] in
which the function changes sign, indicating the presence of a root (i.e., where f(a)⋅f(b) < 0). At
each step, the method calculates the midpoint c = (a + b)/2 and evaluates the function at c.
Depending on the sign of f(c), the method replaces either a or b with c to create a smaller
interval still containing the root. This process continues until the interval is sufficiently small,
giving an approximation of the root. The method is guaranteed to converge for continuous
functions, making it a widely used technique in numerical analysis.
Apparatus:
1. MATLAB Software.
MATLAB Code:
eps_abs = 1e-4;
eps_step= 1e-4;
a = -1.0;
b = 0.0;
d = 0;
while (b-a >= eps_step || (abs(f(a)) >= eps_abs && abs(f(b)) >= eps_abs))
c = (a + b)/2
if f(c) == 0
break;
elseif f(a)*f(c) < 0
b = c;
else
a = c;
end
d = d+1
end
c=
-0.5000
d= 1
c=
-0.7500
d= 2
c=
-0.8750
d= 3
c=
-0.8125
d= 4
c=
-0.7812
d= 5
c=
-0.7656
d= 6
c=
-0.7578
d= 7
c=
-0.7539
d= 8
c=
-0.7559
d= 9
c=
-0.7549
d = 10
c=
-0.7544
d = 11
c=
-0.7546
d = 12
c=
-0.7548
d=
13
c = -0.7548
d=
>> a
a=
14 -0.7549
>> b
b = -0.7548
>> f(c)
ans =
1.4662e-04
Conclusion:
The bisection method is a reliable and easy-to-implement technique for finding roots of
continuous functions, particularly when a sign change is known within a specific interval. Its
guaranteed convergence makes it a dependable choice for solving nonlinear equations,
especially in cases where simplicity and stability are prioritized over speed. Although it may
be slower than methods like Newton-Raphson or the secant method—which utilize derivative
information—the bisection method remains a fundamental and widely used algorithm in
numerical analysis due to its robustness and effectiveness.