50% found this document useful (2 votes)
3K views

Lab Report of BISECTION METHOD

The document describes the bisection method for finding real roots of nonlinear functions. It explains that the bisection method iteratively narrows down the interval that contains the root by bisecting the interval and eliminating half based on the function values. The algorithm repeats this bisection until converging on the root within a specified error tolerance. Advantages are given as always convergent, requiring only one function evaluation per iteration, and not needing derivatives. Disadvantages include inability to find roots where the function is tangent to the x-axis and relatively slow convergence. Pseudocode and a C program implementing the bisection method are also provided.

Uploaded by

Samixa Timalcena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
50% found this document useful (2 votes)
3K views

Lab Report of BISECTION METHOD

The document describes the bisection method for finding real roots of nonlinear functions. It explains that the bisection method iteratively narrows down the interval that contains the root by bisecting the interval and eliminating half based on the function values. The algorithm repeats this bisection until converging on the root within a specified error tolerance. Advantages are given as always convergent, requiring only one function evaluation per iteration, and not needing derivatives. Disadvantages include inability to find roots where the function is tangent to the x-axis and relatively slow convergence. Pseudocode and a C program implementing the bisection method are also provided.

Uploaded by

Samixa Timalcena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Lab Report On Bisection Method

Submitted by:
Ayush Timalsina
Jaya Multiple Campus
BCA 4th Semester
BISECTION METHOD:
Bisection method is an iterative implementation of the
intermediate value theorem to find the real roots of a nonlinear
function. According to the theorem “if a function f(x)=0 is
continuous in an interval (a , b) ,such that f(a) and f(b) are
opposite nature or opposite sign .
Let f(x) be the given function and f(a) and f(b)=f(xb) such that
f(a)-f(b)<0. The root lies between xa and xb .
It shows xa and ab are two initial guesses which bisects the root
.the basic of this algorithm relies on the repeated application of
Let xc = (xa+xb)/2
If fc = f(xc)= 0 , x=xc is the exact root
Fa.fb<0, the root lies in the interval(xa,xc)
Else
Root lies in the interval of (xc,xb)
Advantages:

The bisection method is always convergent.


One function evaluation per iteration .
No knowledge of the derivatives is needed.
The function does not have to be differentiable.

Disadvantages:

It cannot find roots where the function is tangent to the x axis.


Slow to converge.
 It cannot find complex roots of polynomials.
Algorithm
1. Start
2. Read , x1, x2, e
3. Compute f1=f(x1)
F2=f(x2)
4. If f1*f2>0 , display wrong initial guesses
Else continue
5. X= x1+x2/2
6. If ( l X1-X2 l )<e than x and go to f = f’(x)
Else
If f0 * f1 > 0
X1 = x
F1 = f
Else
X2= X
F2 = f
7. Go to step 5
8. Stop
Program:
#include<stdio.h>
#include<conio.h>
#include<math.h>
float fun (float x)
{
return (x*x*x - 6*x*x + 11*x - 6);
}
void bisection (float *x, float a, float b, int *itr)
/* this function performs and prints the result of one iteration
*/
{
*x=(a+b)/2;
++(*itr);
printf("Iteration no. %3d X = %7.5f\n", *itr, *x);
}
int main ()
{
int itr = 0, maxmitr;
float x, a, b, allerr, x1;
printf("\nEnter the values of a, b, allowed error and
maximum iterations:\n");
scanf("%f %f %f %d", &a, &b, &allerr, &maxmitr);
bisection (&x, a, b, &itr);
do
{
if (fun(a)*fun(x) < 0)
b=x;
else
a=x;
bisection (&x1, a, b, &itr);
if (fabs(x1-x) < allerr)
{
printf("After %d iterations, root = %6.4f\n", itr, x1);
return 0;
}
x=x1;
}
while (itr < maxmitr);
printf("The solution does not converge or iterations are not
sufficient");
return 1;
}

Output:
Conclusion:
Hence, The bisection method is a root-finding method that applies
to any continuous functions for which one knows two values with
opposite signs.

Algorithm and program of bisection method are mentioned above.

You might also like