The net.sf.doodleproject.numerics4j.root.Bracket class provides the means to construct an interval known to contain at least one root. This is accomplished by taking a single, initial pivot point and expanding outward from that point until a bracketing interval is formed. Once this interval is created, it can be used as a starting point for root finding routines, such as the bisection method.
Constructing a bracking interval involve creating a
Bracket object for a particular
net.sf.doodleproject.numerics4j.function.Function
object. Once, the bracketer is created, intervals can be created by
calling the bracketOut method providing an initial point
and a lower and upper bound for the interval. The two bounds are not
critical in the construction of the interval and only serve to provide
numerical stability to the algorithm. Here is an example of bracketing
roots for sine:
Function sine = new Function() {
public double evaluate(double x) {
return Math.sin(x);
}
};
Bracket bracket = new Bracket(sine);
// bracket a root near three
double[] containsPi = bracket.bracketOut(-100.0, 3.0, 100.0);
// bracket a root near six
double[] contains2Pi = bracket.bracketOut(-100.0, 6.0, 100.0);