congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
BrentSolver
Code IndexAdd Tabnine to your IDE (free)

How to use
BrentSolver
in
org.apache.commons.math3.analysis.solvers

Best Java code snippets using org.apache.commons.math3.analysis.solvers.BrentSolver (Showing top 20 results out of 315)

origin: org.apache.commons/commons-math3

/**
 * Constructor with default {@link BrentSolver line search solver} and
 * {@link IdentityPreconditioner preconditioner}.
 *
 * @param updateFormula formula to use for updating the β parameter,
 * must be one of {@link ConjugateGradientFormula#FLETCHER_REEVES} or {@link
 * ConjugateGradientFormula#POLAK_RIBIERE}.
 * @param checker Convergence checker.
 */
public NonLinearConjugateGradientOptimizer(final ConjugateGradientFormula updateFormula,
                      ConvergenceChecker<PointValuePair> checker) {
  this(updateFormula,
     checker,
     new BrentSolver(),
     new IdentityPreconditioner());
}
origin: org.apache.commons/commons-math3

    TooManyEvaluationsException,
    NumberIsTooLargeException {
double min = getMin();
double max = getMax();
final double initial = getStartValue();
final double functionValueAccuracy = getFunctionValueAccuracy();
verifySequence(min, initial, max);
double yInitial = computeObjectiveValue(initial);
if (FastMath.abs(yInitial) <= functionValueAccuracy) {
  return initial;
double yMin = computeObjectiveValue(min);
if (FastMath.abs(yMin) <= functionValueAccuracy) {
  return min;
  return brent(min, initial, yMin, yInitial);
double yMax = computeObjectiveValue(max);
if (FastMath.abs(yMax) <= functionValueAccuracy) {
  return max;
  return brent(initial, max, yInitial, yMax);
origin: org.apache.commons/commons-math3

double e = d;
final double t = getAbsoluteAccuracy();
final double eps = getRelativeAccuracy();
    b -= tol;
  fb = computeObjectiveValue(b);
  if ((fb > 0 && fc > 0) ||
    (fb <= 0 && fc <= 0)) {
origin: geogebra/geogebra

/**
 * Brent's algo Copied from AlgoRootInterval.java.
 */
public final static double calcSingleRoot(GeoFunction f, double left,
    double right) {
  BrentSolver rootFinder = new BrentSolver();
  if (!f.isDefined()) {
    return Double.NaN;
  }
  double root = Double.NaN;
  Function fun = f.getFunction();
  try {
    // Brent's method
    root = rootFinder.solve(AlgoRootNewton.MAX_ITERATIONS, fun, left,
        right);
  } catch (Exception e) {
    try {
      // Let's try again by searching for a valid domain first
      double[] borders = RealRootUtil.getDefinedInterval(fun, left,
          right);
      root = rootFinder.solve(AlgoRootNewton.MAX_ITERATIONS, fun,
          borders[0], borders[1]);
    } catch (Exception ex) {
      root = Double.NaN;
    } // try-catch
  } // try-catch
  return root;
}
origin: geogebra/geogebra

BrentSolver rootFinder = new BrentSolver();
  rate = rootFinder.solve(AlgoRootNewton.MAX_ITERATIONS, fun, min,
      max);
origin: geogebra/geogebra

    TooManyEvaluationsException,
    NumberIsTooLargeException {
double min = getMin();
double max = getMax();
final double initial = getStartValue();
final double functionValueAccuracy = getFunctionValueAccuracy();
verifySequence(min, initial, max);
double yInitial = computeObjectiveValue(initial);
if (Math.abs(yInitial) <= functionValueAccuracy) {
  return initial;
double yMin = computeObjectiveValue(min);
if (Math.abs(yMin) <= functionValueAccuracy) {
  return min;
  return brent(min, initial, yMin, yInitial);
double yMax = computeObjectiveValue(max);
if (Math.abs(yMax) <= functionValueAccuracy) {
  return max;
  return brent(initial, max, yInitial, yMax);
origin: org.apache.commons/commons-math3

/**
 * Convenience method to find a zero of a univariate real function.  A default
 * solver is used.
 *
 * @param function Function.
 * @param x0 Lower bound for the interval.
 * @param x1 Upper bound for the interval.
 * @param absoluteAccuracy Accuracy to be used by the solver.
 * @return a value where the function is zero.
 * @throws NoBracketingException if the function has the same sign at the
 * endpoints.
 * @throws NullArgumentException if {@code function} is {@code null}.
 */
public static double solve(UnivariateFunction function,
              double x0, double x1,
              double absoluteAccuracy)
  throws NullArgumentException,
      NoBracketingException {
  if (function == null) {
    throw new NullArgumentException(LocalizedFormats.FUNCTION);
  }
  final UnivariateSolver solver = new BrentSolver(absoluteAccuracy);
  return solver.solve(Integer.MAX_VALUE, function, x0, x1);
}
origin: geogebra/geogebra

double e = d;
final double t = getAbsoluteAccuracy();
final double eps = getRelativeAccuracy();
    b -= tol;
  fb = computeObjectiveValue(b);
  if ((fb > 0 && fc > 0) ||
    (fb <= 0 && fc <= 0)) {
origin: geogebra/geogebra

rootFinder = new BrentSolver();
root = rootFinder.solve(AlgoRootNewton.MAX_ITERATIONS, fun, min,
    max);
  root = rootFinder.solve(AlgoRootNewton.MAX_ITERATIONS, fun,
      borders[0],
      borders[1]);
origin: io.virtdata/virtdata-lib-realer

    TooManyEvaluationsException,
    NumberIsTooLargeException {
double min = getMin();
double max = getMax();
final double initial = getStartValue();
final double functionValueAccuracy = getFunctionValueAccuracy();
verifySequence(min, initial, max);
double yInitial = computeObjectiveValue(initial);
if (FastMath.abs(yInitial) <= functionValueAccuracy) {
  return initial;
double yMin = computeObjectiveValue(min);
if (FastMath.abs(yMin) <= functionValueAccuracy) {
  return min;
  return brent(min, initial, yMin, yInitial);
double yMax = computeObjectiveValue(max);
if (FastMath.abs(yMax) <= functionValueAccuracy) {
  return max;
  return brent(initial, max, yInitial, yMax);
origin: org.apache.commons/commons-math3

/**
 * Convenience method to find a zero of a univariate real function.  A default
 * solver is used.
 *
 * @param function Function.
 * @param x0 Lower bound for the interval.
 * @param x1 Upper bound for the interval.
 * @return a value where the function is zero.
 * @throws NoBracketingException if the function has the same sign at the
 * endpoints.
 * @throws NullArgumentException if {@code function} is {@code null}.
 */
public static double solve(UnivariateFunction function, double x0, double x1)
  throws NullArgumentException,
      NoBracketingException {
  if (function == null) {
    throw new NullArgumentException(LocalizedFormats.FUNCTION);
  }
  final UnivariateSolver solver = new BrentSolver();
  return solver.solve(Integer.MAX_VALUE, function, x0, x1);
}
origin: io.virtdata/virtdata-lib-realer

double e = d;
final double t = getAbsoluteAccuracy();
final double eps = getRelativeAccuracy();
    b -= tol;
  fb = computeObjectiveValue(b);
  if ((fb > 0 && fc > 0) ||
    (fb <= 0 && fc <= 0)) {
origin: geogebra/geogebra

double root = Double.NaN;
if (rootFinderBrent == null) {
  rootFinderBrent = new BrentSolver(Kernel.STANDARD_PRECISION);
  root = rootFinderBrent.solve(MAX_ITERATIONS, fun, startX - step,
      startX + step,
      startX);
  root = rootFinderBrent.solve(MAX_ITERATIONS, fun, borders[0],
      borders[1], startX);
  if (checkRoot(fun, root)) {
origin: io.virtdata/virtdata-lib-realer

/**
 * Constructor with default {@link BrentSolver line search solver} and
 * {@link IdentityPreconditioner preconditioner}.
 *
 * @param updateFormula formula to use for updating the &beta; parameter,
 * must be one of {@link ConjugateGradientFormula#FLETCHER_REEVES} or {@link
 * ConjugateGradientFormula#POLAK_RIBIERE}.
 * @param checker Convergence checker.
 */
public NonLinearConjugateGradientOptimizer(final ConjugateGradientFormula updateFormula,
                      ConvergenceChecker<PointValuePair> checker) {
  this(updateFormula,
     checker,
     new BrentSolver(),
     new IdentityPreconditioner());
}
origin: geogebra/geogebra

/**
 * Convenience method to find a zero of a univariate real function.  A default
 * solver is used.
 *
 * @param function Function.
 * @param x0 Lower bound for the interval.
 * @param x1 Upper bound for the interval.
 * @return a value where the function is zero.
 * @throws NoBracketingException if the function has the same sign at the
 * endpoints.
 * @throws NullArgumentException if {@code function} is {@code null}.
 */
public static double solve(UnivariateFunction function, double x0, double x1)
  throws NullArgumentException,
      NoBracketingException {
  if (function == null) {
    throw new NullArgumentException(LocalizedFormats.FUNCTION);
  }
  final UnivariateSolver solver = new BrentSolver();
  return solver.solve(Integer.MAX_VALUE, function, x0, x1);
}
origin: geogebra/geogebra

/**
 * Convenience method to find a zero of a univariate real function.  A default
 * solver is used.
 *
 * @param function Function.
 * @param x0 Lower bound for the interval.
 * @param x1 Upper bound for the interval.
 * @param absoluteAccuracy Accuracy to be used by the solver.
 * @return a value where the function is zero.
 * @throws NoBracketingException if the function has the same sign at the
 * endpoints.
 * @throws NullArgumentException if {@code function} is {@code null}.
 */
public static double solve(UnivariateFunction function,
              double x0, double x1,
              double absoluteAccuracy)
  throws NullArgumentException,
      NoBracketingException {
  if (function == null) {
    throw new NullArgumentException(LocalizedFormats.FUNCTION);
  }
  final UnivariateSolver solver = new BrentSolver(absoluteAccuracy);
  return solver.solve(Integer.MAX_VALUE, function, x0, x1);
}
origin: io.virtdata/virtdata-lib-realer

/**
 * Convenience method to find a zero of a univariate real function.  A default
 * solver is used.
 *
 * @param function Function.
 * @param x0 Lower bound for the interval.
 * @param x1 Upper bound for the interval.
 * @return a value where the function is zero.
 * @throws NoBracketingException if the function has the same sign at the
 * endpoints.
 * @throws NullArgumentException if {@code function} is {@code null}.
 */
public static double solve(UnivariateFunction function, double x0, double x1)
  throws NullArgumentException,
      NoBracketingException {
  if (function == null) {
    throw new NullArgumentException(LocalizedFormats.FUNCTION);
  }
  final UnivariateSolver solver = new BrentSolver();
  return solver.solve(Integer.MAX_VALUE, function, x0, x1);
}
origin: io.virtdata/virtdata-lib-realer

/**
 * Convenience method to find a zero of a univariate real function.  A default
 * solver is used.
 *
 * @param function Function.
 * @param x0 Lower bound for the interval.
 * @param x1 Upper bound for the interval.
 * @param absoluteAccuracy Accuracy to be used by the solver.
 * @return a value where the function is zero.
 * @throws NoBracketingException if the function has the same sign at the
 * endpoints.
 * @throws NullArgumentException if {@code function} is {@code null}.
 */
public static double solve(UnivariateFunction function,
              double x0, double x1,
              double absoluteAccuracy)
  throws NullArgumentException,
      NoBracketingException {
  if (function == null) {
    throw new NullArgumentException(LocalizedFormats.FUNCTION);
  }
  final UnivariateSolver solver = new BrentSolver(absoluteAccuracy);
  return solver.solve(Integer.MAX_VALUE, function, x0, x1);
}
origin: meyerjp3/psychometrics

int ncat = 0;
RpFunction func = null;
UnivariateSolver solver = new BrentSolver(1.0e-12, 1.0e-8);
HashMap<String, Double> unsortedMap = new HashMap<String, Double>();
origin: org.appdapter/ext.bundle.math.symja_jas

  solver = new BisectionSolver();
} else if (method.equals("Brent")) {
  solver = new BrentSolver();
org.apache.commons.math3.analysis.solversBrentSolver

Javadoc

This class implements the Brent algorithm for finding zeros of real univariate functions. The function should be continuous but not necessarily smooth. The solve method returns a zero x of the function fin 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

Most used methods

  • <init>
    Construct a solver.
  • brent
    Search for a zero inside the provided interval. This implementation is based on the algorithm descri
  • computeObjectiveValue
  • getAbsoluteAccuracy
  • getFunctionValueAccuracy
  • getMax
  • getMin
  • getRelativeAccuracy
  • getStartValue
  • verifySequence
  • solve
  • solve

Popular in Java

  • Reading from database using SQL prepared statement
  • getResourceAsStream (ClassLoader)
  • getApplicationContext (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • JTable (javax.swing)
  • Top 17 Plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now