Bisection Method Implementation I'm working on a program to program the bisection method:
https://www.calculushowto.com/bisection-method/
I know there's questions similar to this one but I want to see if my own one works.
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;       
}

func() is the function I'm using to test the bisection method. In the other function, a is the left point, b is the right point and e is the error bound.
Any mistakes that I didn't catch?
You seem to assume that there is a root between a and b. If it is not the case, bisect will never terminate. Assuming that f is well-behaving, it would be prudent to test that f(a) and f(b) have different signs before proceeding.
Also, consider the case f(a) &gt; 0 &amp;&amp; f(b) &lt; 0

bisect doesn't find the approximation of the root. It finds an argument at which f is reasonably small. It could be quite far from the root. A prudent termination condition is b - a &lt; e.

a + b may overflow, and then all bets are off. Consider mid = a + (b - a)/2.