BOOL bracketOutWithState(FunctionWithState func, void* state, double* x0, double* x1)
Given a function func (parameterized by state) and an initial range (x0, x1), the range is expanded until a root is bracketed by the returned values (x0, x1). If a root is bracketed, TRUE is returned. Otherwise, FALSE is returned.
Parameters:
func | Function to find root for. |
---|---|
state | Parameters used by func. |
x0 | Lower bound of root. |
x1 | Upper bound of root. |
Returns:
On return, x0 and x1 form an interval which contains at least one root of func.
Usage:
typedef struct { double value; } state_t; double square(double x, void* state) { return x * x - ((state_t*)s)->value; } state_t state = {5.0}; double x0 = 1.0, x1 = 2.0; bracketOutWithState(square, &state, &x0, &x1);
Header:
#include "rootfind.h"
See Also: FunctionWithState