Bisection method is an iterative method used for the solution of non-linear equations, also known as binary chopping or half-interval method.

Bisection method is based on the repeated application of the intermediate value property. It means if f(x) is continuous in the interval [a, b] and f(a) and f(b) have different sign then the equation f(x) = 0 has at least one root between x = a and x = b.

This method is most reliable and simplest iterative method for solution of nonlinear equation.

a < x < b

where, x is not of nonlinear equation.

Let f(x) = 0 be continuous between ‘a’ and ‘b’. By definition let f(a) be negative and f(b) be positive. The first approximation to the root is

;

Where, a and b is selected such that,

Now, if f(x_{1}) = 0 the x_{1} is the root of f(x) otherwise the root lies between ‘a’ and x_{1} or x_{1} and ‘b’ according as f(x_{1}) is positive or negative. Then we bisect the interval as before and continue the process until the root is found to desired accuracy.

## Algorithm of Bisection Method

Step 1: | Start |

Step 2: | Define function f(x) and error (E) |

Step 3: | Take two initial value for root as x_{1} and x_{2}. |

Step 4: | Compute f(x_{1}) and f(x_{2}) |

Step 5: | If , then x_{1} and x_{2} do not coverage and root does not lies in between x_{1} and x_{2 }and go to step (10); Otherwise continue. |

Step 6: | If f(x_{1}) < 0 then set a = x_{1} and b = x_{2}
Else, Set a = x |

Step 7: | Calculate root, and also calculate f(x_{n}). |

Step 8: | If f(x_{n}) > 0 (i.e. positive) then,
Set b =x else, set a = x |

Step 9: | Repeat till step (8), until absolute value of is less then E, then display root.
, go to step (10), ese to step (7). |

Step 10: | Stop |

## Pseudocode of Bisection Method

Input f(x), e

Repeat

Input x_{1} and x_{2} till

Repeat

If assign x_{2} = 0

Else assign x_{1} = x_{0 }till |x_{2} – x_{1}| > e

Display root = x_{0}

## C Source Code of Bisection Method

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
#include <stdio.h> #include <math.h> #define f(x) pow(x,2) – 4*x-10 #define e 0.0001 Void main() { float x, x1, x2, x0; do { printf (“Enter the value of x1 and x2\n”); scanf(“%f %f”, &x1, &x2); } while (f(x1)*f(x2)>0); do { x0 = (x1 + x2)/2; if((f(x1)*f(x2))<0) { x2 = x0; } else x1 = x0; x = (x1 + x2)/2; }while (fabs(x0 - x)>e); printf(“root is =”, x0); getch(); } |

C++ Source code of bisection method

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
#include <iostream> #include <cmath> #define f(x) pow(x,2)-4*x-10 #define e 0.0001 using namespace std; int main() { float x, x2, x3, x0; do { cout<<”Enter the value of x1 and x2”<<endl; cin>>x1>>x2; } while(f(x1)*f(x2)>0); do { x0 = (x1 + x2)/2; if((f(x1)*f(x2))<0) { x2 = x0; } else x1 = x0; x = (x1 + x2)/2; }while(fabs(x0-x)>e); cout<<”Root is =”<<x0 <<endl; getch(); return 0; } |

Output: Enter the value of x_{1} and x_{2}

1

-3

Root is = 0.999878