title: Bisection Method Implementation
body: <p>I'm working on a program to program the bisection method:
  <a href="https://www.calculushowto.com/bisection-method/" rel="nofollow noreferrer">https://www.calculushowto.com/bisection-method/</a></p>
  <p>I know there's questions similar to this one but I want to see if my own one works.</p>
  <pre><code>double func(double x) {
      return x * x - 3 * x - 1;
  }
      
  double bisect(double (*f)(double), double a, double b, double e) {
      double mid = (a + b) / 2;
      while (abs(mid) &gt; e) {
          if (f(mid) &lt; 0) {
              mid = a;
          } else {
              mid = b;
          }
      }
        
      return mid;       
  }
  </code></pre>
  <p><code>func()</code> is the function I'm using to test the bisection method. In the other function, <code>a</code> is the left point, <code>b</code> is the right point and <code>e</code> is the error bound.</p>
  <p>Any mistakes that I didn't catch?</p>