Chapter:

bisection-method

1.

TITLE: 

TO FIND THE ROOTS OF NON-LINEAR EQUATION USING BISECTION  METHOD

 OBJECTIVES:

  • To be able to follow the algorithm of Bisection method of solving non linear equation.

  • To use the Bisection method to solve examples of finding roots of a non linear equation.

  • To build some programming concepts by solving practical problems.

 TOOLS REQUIRED:

  • Computer workstation

  • Program software (as necessary)

 THEORY:

The bisection method in mathematics, also known as binary chopping or half interval method, is a root finding method that repeatedly bisects an interval and then select an subinterval in which a root must lie for further processing and relies on the fact that if f (x) is real and continuous in the interval a

f (a)*f (b)<0

then there is at least one real riot in the interval  between a and b.

Its strategy is to begin with two values of x say a and b that bisects the root of f (x)=0. This method treats the interval distance between the initial values as line segments  and then successively divides the interval in half and replace the one end point with the midpoint so that the root is again bracketed.

 ALGORITHM:

  1. Start

  2. Define function f (x) and stopping criteria E.

  3. Decide initial values of x as a and b.

  4. Compute f (a) and f (b).

  5. If f (a)*f (b)>0 then a and b does not converge and root does not lies between a and b. Go to step 10. Otherwise continue.

  6. If `f (x_1)<0` then set `a=x_1` and `b=x_2` otherwise set `a=x_2` and `b=x_1`

  7. Calculate `c=(a+b)/2` and f (c).

  8. if `f(c)> 0` set `b=c` else set `a=c`.

  9. Repeat step 8 until the absolute value of `abs ((b-a)/a)

  10. Stop.


 C-PROGRAM:   

//Bisection Method
#include
#include
#include
#define f(x) cos(x) - x * exp(x)
void main()
{
	 float x0, x1, x2, f0, f1, f2, e;
	 int step = 1;
	 clrscr();
	 up:
	 printf("\nEnter two initial guesses:\n");
	 scanf("%f%f", &x0, &x1);
	 printf("Enter tolerable error:\n");
	 scanf("%f", &e);
	 f0 = f(x0);
	 f1 = f(x1);
	 if( f0 * f1 > 0.0)
	 {
	    printf("Incorrect Initial Guesses.\n");
            goto up;
	 }
	 printf("\nStep\t\tx0\t\tx1\t\tx2\t\tf(x2)\n");
	 do
	 {
	   x2 = (x0 + x1)/2;
           f2 = f(x2);
	   printf("%d\t\t%f\t%f\t%f\t%f\n",step, x0, x1, x2, f2);
		  if( f0 * f2 < 0)
{ x1 = x2; f1 = f2; } else { x0 = x2; f0 = f2; } step = step + 1; }while(fabs(f2)>e); printf("\nRoot is: %f", x2); getch(); }

CONCLUSION:

Thus the roots of the given non linear equation was found  out using Bisection method.


Show More