bisection

double bisection(Function func, double x0, double x1, double tol)

Returns the root of func bracketed between x0 and x1 using the bisection method. The returned root is within tol of the true value of the root.

Parameters:
funcFunction to find root for.
x0Lower bound of root.
x1Upper bound of root.
tolMaximum error tolerance.

Returns:
The value x, such that func(x) = 0.

Usage:

double sine(double x) { return sin(x); }
double x = bisection(sine, 2.3, 3.4);

Header:
#include "rootfind.h"