title: Recursive bisection method program stopped working
body: <p>I have a problem with bisection method (recursive implementation) that doesn't work.  The program just crashes after entering a&amp;b values ...</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;iostream&gt;
  #define e 0.0001
  #define dbg 1
  using namespace std;
  double f(double x){
      return x*x*x-x-2;
  }
  double bisection(double a,double b){
      double x1;
      x1=(b+a)/2;
      if(x1&gt;e){
          if(f(b)*f(x1)&lt;0)
          {
              a=x1;
          }
          else
          if(f(a)*f(x1)&lt;0)
              b=x1;
          bisection(a,b);
          }
      return x1;
  }
  int main () {
      int a,b;
      double root;
      printf("a=");
      scanf("%d",&amp;a);
      printf("b=");
      scanf("%d",&amp;b);
      if(f(a)*f(b)&lt;0){
          root=bisection(a,b);
          printf("root %g",root);
      }
  
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>I have tried to display some debugging messages, but I couldn't figure it out.</p>