double secant(Function func, double x0, double x1, double tol)
Returns the root of func using the secant method with initial approximations x0 and x1. The returned root is within tol of the true value of the root.
Parameters:
func | Function to find root for. |
---|---|
x0 | Lower bound of root. |
x1 | Upper bound of root. |
tol | Maximum error tolerance. |
Returns:
The value x, such that func(x) = 0.
Usage:
double sine(double x) { return sin(x); } double x = secant(sine, 2.3, 3.4);
Header:
#include "rootfind.h"