Package smile.math

Class Root

java.lang.Object
smile.math.Root

public class Root extends Object
Root finding algorithms.
  • Method Details

    • find

      public static double find(Function func, double x1, double x2, double tol, int maxIter)
      Brent's method for root-finding. It combines the bisection method, the secant method and inverse quadratic interpolation. It has the reliability of bisection, but it can be as quick as some of the less-reliable methods. The algorithm tries to use the potentially fast-converging secant method or inverse quadratic interpolation if possible, but it falls back to the more robust bisection method if necessary.

      The method is guaranteed to converge as long as the function can be evaluated within the initial interval known to contain a root.

      Parameters:
      func - the function to be evaluated.
      x1 - the left end of search interval.
      x2 - the right end of search interval.
      tol - the desired accuracy (convergence tolerance).
      maxIter - the maximum number of iterations.
      Returns:
      the root.
    • find

      public static double find(DifferentiableFunction func, double x1, double x2, double tol, int maxIter)
      Newton's method (also known as the Newton–Raphson method). This method finds successively better approximations to the roots of a real-valued function. Newton's method assumes the function to have a continuous derivative. Newton's method may not converge if started too far away from a root. However, when it does converge, it is faster than the bisection method, and is usually quadratic. Newton's method is also important because it readily generalizes to higher-dimensional problems. Newton-like methods with higher orders of convergence are the Householder's methods.
      Parameters:
      func - the function to be evaluated.
      x1 - the left end of search interval.
      x2 - the right end of search interval.
      tol - the desired accuracy (convergence tolerance).
      maxIter - the maximum number of iterations.
      Returns:
      the root.