Bisection Method – numerical Method

Spread the love

Bisection Method

Bisection Method

Bisection Method | This method is known as Bolzano method, bracketing method, binary chopping method or half interval method.

Suppose we are given the continuous function f(x) in the interval [p, q] and we want to find the root of the equation f(x)=0 by a bisection method. The process is described as follows:-
1)      Find two points a and b such that f(a) * f(b) < 0. That is finding a and b so that f(a) and f(b) are of opposite sign. This process is called finding the initial root.
2)      Compute the middle point c using relation c= (a+b)/2. If f(c) = 0 then ‘c’ is the required root & stop the process if f (c) 0 then go to next step.
3)      If f(a) * f (c) <0 then root lies between a & c otherwise the root lies between c & b.
4)      Repeat step 2 & 3 until the root is found to be desired of accuracy.

Code:

#include<stdio.h>
#include<conio.h>
float f(float x){
            return (x*x*x-4*x-9);
            }
void main(){
            int i,n;
            float a,b,c;
            clrscr();           
            printf(“Enter the no of iteration:”);
            scanf(“%d”,&n);
            printf(“enter two values where the root lies:”);
            scanf(“%f %f”,&a,&b);
            if(f(a)*f(b)>0)
              {
                 printf(“the initial values are out of range”);
                 getch();
                  exit(0);
              }
            else{
                        for(i=1;i<=n;i++){
                        c=(a+b)/2;
                        if(f(c)==0)
                                     break;
                        if(f(a)*f(c)<0)
                                    b=c;
                        else
                                    a=c;
            }
            printf(“the reqd. root is:%f”,c);
            getch();
            }
}

False position method


Spread the love

Santosh Adhikari

Hello, it's me Santosh Adhikari, from Kathmandu, Nepal. I'm a student of Science and Technology. I love new challenges and want to explore more on Software Quality Assurance. I want to be a professional SQA. I'm also interested in Blogging, SEO activities.
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments