ROOT logo
ROOT » MATH » MATHCORE » ROOT::Math::BrentRootFinder

class ROOT::Math::BrentRootFinder: public ROOT::Math::IRootFinderMethod


   Class for finding the root of a one dimensional function using the Brent algorithm.
   It will use the Brent Method for finding function roots in a given interval.
   First, a grid search is used to bracket the root value
   with the a step size = (xmax-xmin)/npx. The step size
   can be controlled via the SetNpx() function. A default value of npx = 100 is used.
   The default value con be changed using the static method SetDefaultNpx.
   If the function is unimodal or if its extrema are far apart, setting the fNpx to
   a small value speeds the algorithm up many times.
   Then, Brent's method is applied on the bracketed interval.
   It will use the Brent Method for finding function roots in a given interval.
   If the Brent method fails to converge the bracketing is repeted on the latest best estimate of the
   interval. The procedure is repeted with a maximum value (default =10) which can be set for all
   BrentRootFinder classes with the method SetDefaultNSearch

   This class is implemented from TF1::GetX() method.

   @ingroup RootFinders


Function Members (Methods)

public:
virtual~BrentRootFinder()
ROOT::Math::BrentRootFinderBrentRootFinder()
ROOT::Math::BrentRootFinderBrentRootFinder(const ROOT::Math::BrentRootFinder&)
virtual intROOT::Math::IRootFinderMethod::Iterate()
virtual intIterations() const
virtual const char*Name() const
ROOT::Math::IRootFinderMethod&ROOT::Math::IRootFinderMethod::operator=(const ROOT::Math::IRootFinderMethod&)
virtual doubleRoot() const
static voidSetDefaultNpx(int npx)
static voidSetDefaultNSearch(int n)
virtual boolSetFunction(const ROOT::Math::IGenFunction& f, double xlow, double xup)
voidSetLogScan(bool on)
voidSetNpx(int npx)
virtual boolSolve(int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10)
virtual intStatus() const

Data Members

private:
const ROOT::Math::IGenFunction*fFunctionPointer to the function.
boolfLogScanflag to control usage of a log scan
intfNIterNumber of iterations needed for the last estimation.
intfNpxNumber of points to bracket root with initial grid (def is 100)
doublefRootCurrent stimation of the function root.
intfStatusStatus of code of the last estimate
doublefXMaxUpper bound of the search interval
doublefXMinLower bound of the search interval.

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

BrentRootFinder()
 Default Constructor. 
virtual ~BrentRootFinder()
 Default Destructor. 
{}
bool SetFunction(const ROOT::Math::IGenFunction& f, double xlow, double xup)
bool Solve(int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10)
 Returns the X value corresponding to the function value fy for (xmin<x<xmax).
          Method:
          First, the grid search is used to bracket the maximum
          with the step size = (xmax-xmin)/fNpx. This way, the step size
          can be controlled via the SetNpx() function. If the function is
          unimodal or if its extrema are far apart, setting the fNpx to
          a small value speeds the algorithm up many times.
          Then, Brent's method is applied on the bracketed interval.

          \@param maxIter maximum number of iterations.
          \@param absTol desired absolute error in the minimum position.
          \@param absTol desired relative error in the minimum position.

void SetNpx(int npx)
 Set the number of point used to bracket root using a grid 
{ fNpx = npx; }
void SetLogScan(bool on)
          Set a log grid scan (default is equidistant bins)
          will work only if xlow > 0

{ fLogScan = on; }
double Root() const
 Returns root value. Need to call first Solve(). 
{ return fRoot; }
int Status() const
 Returns status of last estimate. If = 0 is OK 
{ return fStatus; }
int Iterations() const
 Return number of iteration used to find minimum 
{ return fNIter; }
const char* Name() const
 Return name of root finder algorithm ("BrentRootFinder"). 
void SetDefaultNpx(int npx)
 static function used to modify the default parameters
 set number of default Npx used at construction time (when SetNpx is not called)
          Default value is 100

void SetDefaultNSearch(int n)
 set number of  times the bracketing search in combination with is done to find a good interval
          Default value is 10