public class BrentSolver extends Object
solve method returns a zero x of the function f
in the given interval [a, b] to within a tolerance
2 eps abs(x) + t where eps is the relative accuracy and
t is the absolute accuracy.
The given interval must bracket the root.
The reference implementation is given in chapter 4 of
Algorithms for Minimization Without Derivatives, Richard P. Brent, Dover, 2002
| Constructor and Description |
|---|
BrentSolver(double relativeAccuracy,
double absoluteAccuracy,
double functionValueAccuracy)
Construct a solver.
|
| Modifier and Type | Method and Description |
|---|---|
double |
findRoot(DoubleUnaryOperator func,
double min,
double max)
Search the function's zero within the given interval.
|
double |
findRoot(DoubleUnaryOperator func,
double min,
double initial,
double max)
Search the function's zero within the given interval,
starting from the given estimate.
|
public BrentSolver(double relativeAccuracy, double absoluteAccuracy, double functionValueAccuracy)
relativeAccuracy - Relative accuracy.absoluteAccuracy - Absolute accuracy.functionValueAccuracy - Function value accuracy.public double findRoot(DoubleUnaryOperator func, double min, double max)
func - Function to solve.min - Lower bound.max - Upper bound.IllegalArgumentException - if min > max.IllegalArgumentException - if the given interval does
not bracket the root.public double findRoot(DoubleUnaryOperator func, double min, double initial, double max)
func - Function to solve.min - Lower bound.initial - Initial guess.max - Upper bound.IllegalArgumentException - if min > max or
initial is not in the [min, max] interval.IllegalArgumentException - if the given interval does
not bracket the root.Copyright © 2017–2022 The Apache Software Foundation. All rights reserved.