/** * Check that the endpoints specify an interval. * * @param lower Lower endpoint. * @param upper Upper endpoint. * @throws NumberIsTooLargeException if {@code lower >= upper}. */ protected void verifyInterval(final double lower, final double upper) throws NumberIsTooLargeException { UnivariateSolverUtils.verifyInterval(lower, upper); }
/** {@inheritDoc} */ public double solve(final int maxEval, final UnivariateFunction f, final double min, final double max, final AllowedSolution allowedSolution) { return solve(maxEval, f, min, max, min + 0.5 * (max - min), allowedSolution); }
/** {@inheritDoc} */ public double solve(final int maxEval, final UnivariateFunction f, final double min, final double max, final double startValue, final AllowedSolution allowedSolution) { this.allowed = allowedSolution; return super.solve(maxEval, f, min, max, startValue); }
/** * Find a zero near the midpoint of {@code min} and {@code max}. * * @param f Function to solve. * @param min Lower bound for the interval. * @param max Upper bound for the interval. * @param maxEval Maximum number of evaluations. * @return the value where the function is zero. * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum evaluation count is exceeded. * @throws org.apache.commons.math3.exception.NumberIsTooLargeException * if {@code min >= max}. */ @Override public double solve(int maxEval, final DifferentiableUnivariateFunction f, final double min, final double max) throws TooManyEvaluationsException { return super.solve(maxEval, f, UnivariateSolverUtils.midpoint(min, max)); }
/** * Find a zero near the midpoint of {@code min} and {@code max}. * * @param f Function to solve. * @param min Lower bound for the interval. * @param max Upper bound for the interval. * @param maxEval Maximum number of evaluations. * @return the value where the function is zero. * @throws org.apache.commons.math3.exception.TooManyEvaluationsException * if the maximum evaluation count is exceeded. * @throws org.apache.commons.math3.exception.NumberIsTooLargeException * if {@code min >= max}. */ @Override public double solve(int maxEval, final UnivariateDifferentiableFunction f, final double min, final double max) throws TooManyEvaluationsException { return super.solve(maxEval, f, UnivariateSolverUtils.midpoint(min, max)); }
/** {@inheritDoc} */ public double solve(int maxEval, FUNC f, double startValue) throws TooManyEvaluationsException, NoBracketingException { return solve(maxEval, f, Double.NaN, Double.NaN, startValue); }
/** * {@inheritDoc} */ @Override protected void setup(int maxEval, PolynomialFunction f, double min, double max, double startValue) { super.setup(maxEval, f, min, max, startValue); polynomialFunction = f; }
/** * Check whether the arguments form a (strictly) increasing sequence. * * @param start First number. * @param mid Second number. * @param end Third number. * @return {@code true} if the arguments form an increasing sequence. */ protected boolean isSequence(final double start, final double mid, final double end) { return UnivariateSolverUtils.isSequence(start, mid, end); }
/** * Check whether the function takes opposite signs at the endpoints. * * @param lower Lower endpoint. * @param upper Upper endpoint. * @return {@code true} if the function values have opposite signs at the * given points. */ protected boolean isBracketing(final double lower, final double upper) { return UnivariateSolverUtils.isBracketing(function, lower, upper); }
/** * Check that the endpoints specify an interval and the function takes * opposite signs at the endpoints. * * @param lower Lower endpoint. * @param upper Upper endpoint. * @throws NullArgumentException if the function has not been set. * @throws NoBracketingException if the function has the same sign at * the endpoints. */ protected void verifyBracketing(final double lower, final double upper) throws NullArgumentException, NoBracketingException { UnivariateSolverUtils.verifyBracketing(function, lower, upper); }
/** * Check that {@code lower < initial < upper}. * * @param lower Lower endpoint. * @param initial Initial value. * @param upper Upper endpoint. * @throws NumberIsTooLargeException if {@code lower >= initial} or * {@code initial >= upper}. */ protected void verifySequence(final double lower, final double initial, final double upper) throws NumberIsTooLargeException { UnivariateSolverUtils.verifySequence(lower, initial, upper); }
/** * Get the absolute accuracy. * @return absolute accuracy */ @Override public Dfp getAbsoluteAccuracy() { return super.getAbsoluteAccuracy(); }
/** * Get the function accuracy. * @return function accuracy */ @Override public Dfp getFunctionValueAccuracy() { return super.getFunctionValueAccuracy(); }
/** * Get the relative accuracy. * @return relative accuracy */ @Override public Dfp getRelativeAccuracy() { return super.getRelativeAccuracy(); }
/** {@inheritDoc} */ public double solve(int maxEval, FUNC f, double min, double max) { return solve(maxEval, f, min, max, min + 0.5 * (max - min)); }
/** * Check that {@code lower < initial < upper}. * * @param lower Lower endpoint. * @param initial Initial value. * @param upper Upper endpoint. * @throws NumberIsTooLargeException if {@code lower >= initial} or * {@code initial >= upper}. */ public static void verifySequence(final double lower, final double initial, final double upper) throws NumberIsTooLargeException { verifyInterval(lower, initial); verifyInterval(initial, upper); }
/** {@inheritDoc} */ @Override public double solve(final int maxEval, final UnivariateFunction f, final double min, final double max, final double startValue) { return solve(maxEval, f, min, max, startValue, AllowedSolution.ANY_SIDE); }
/** {@inheritDoc} */ public double solve(int maxEval, UnivariateFunction f, double min, double max, double startValue, AllowedSolution allowedSolution) throws TooManyEvaluationsException, NumberIsTooLargeException, NoBracketingException { this.allowed = allowedSolution; return super.solve(maxEval, f, min, max, startValue); }
/** * {@inheritDoc} */ @Override protected void setup(int maxEval, UnivariateDifferentiableFunction f, double min, double max, double startValue) { super.setup(maxEval, f, min, max, startValue); function = f; } }