Function fn, double lower, double upper, double tol) {
BrentOptimizer optimizer = new BrentOptimizer();
optimizer.setAbsoluteAccuracy(tol);
try {
return optimizer.optimize(new UnivariateRealClosure(context, rho, fn), GoalType.MINIMIZE, lower, upper);
} catch (MaxIterationsExceededException e) {
throw new EvalException("maximum iterations reached", e);
} catch (FunctionEvaluationException e) {
throw new EvalException(e);
}