Numerical Program

Bisection Program Definition

The bisection method in mathematics is a root-finding method that repeatedly bisects an interval and then selects a subinterval in which a root must lie for further processing. It is a very simple and robust method, but it is also relatively slow.

Equation: x2-10

Features of Bisection Method:

  • Type – closed bracket
  • No. of initial guesses – 2
  • Convergence – linear
  • Rate of convergence – slow but steady
  • Accuracy – good
  • Programming effort – easy
  • Approach – middle point

Program of Bisection Method in C Language

  #include<stdio.h>
  #include<conio.h>
  #include<math.h> 
  // #define f(x) x*x-10 float f(float x)
  
  float f(float x)
  {
     float z;
     z=x*x-10;
     return z;
  }
  
  void main()
  {
     int count=1,n;
     float a,b,m;
     clrscr(); 
     printf("ENTER THE INTERVALS A and B :- ");
     xyz: 
     scanf("%f%f",&a,&b); 
     printf("No.of Iteration.");
     scanf("%d",&n);
     if(f(a)*f(b)<0);
     {
      m=(a+b)/2;
      while(count<=n)
       {
       if(f(a)*f(m)<0)
         {
           b=m;
         }
      else
      {
          a=m;
      }
       count++;
       m=(a+b)/2;
     }
     printf("Answer is : %f",m);
    }
  
    getch();
   }
    

Output

Post Your Comment

Some Useful Tricks of Windows

Follow us on Facebook

Advertisement