Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ModABRootFinder.h
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Authors: Nedelcho Ganchovski 03/03/2026
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2026 CERN *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 * *
12 **********************************************************************/
13
14// Header for the RootFinder
15//
16// Created by: Nedelcho Ganchovski : Wed March 03 2026
17//
18
19#ifndef ROOT_Math_ModABRootFinder
20#define ROOT_Math_ModABRootFinder
21
22#include "Math/IFunction.h"
24
25namespace ROOT::Math {
26
27//___________________________________________________________________________________________
28/**
29 Class for finding the root of a one dimensional function using the ModAB algorithm.
30 It is based on the Modified Anderson-Björck method (2022 Ganchovski & Traykov) that
31 adaptively switches between bisection and regula-falsi with
32 side-correction, yielding superlinear convergence on well-behaved
33 functions while retaining the robustness of bisection.
34 @ingroup RootFinders
35 */
36
38public:
39 /** Set function to solve and the interval in where to look for the root.
40
41 \@param f Function to be minimized.
42 \@param xlow Lower bound of the search interval.
43 \@param xup Upper bound of the search interval.
44 */
46 bool SetFunction(const ROOT::Math::IGenFunction &f, double xlow, double xup) override;
47
48 /** Returns the X value corresponding to the function value fy for (xmin<x<xmax).
49 Method:
50 Modified Anderson-Björck method is applied on the bracketed interval.
51
52 \@param maxIter maximum number of iterations.
53 \@param absTol desired absolute error in the minimum position.
54 \@param relTol desired relative error in the minimum position.
55 */
56 bool Solve(int maxIter = 100, double absTol = 1E-8, double relTol = 1E-10) override;
57
58 /** Returns root value. Need to call first Solve(). */
59 double Root() const override { return fRoot; }
60
61 /** Returns status of last estimate. If = 0 is OK */
62 int Status() const override { return fStatus; }
63
64 /** Return number of iteration used to find minimum */
65 int Iterations() const override { return fNIter; }
66
67 /** Return name of root finder algorithm ("ModABRootFinder"). */
68 const char *Name() const override;
69
70private:
71 const IGenFunction *fFunction = nullptr; // Pointer to the function.
72 int fNIter = 0; // Number of iterations needed for the last estimation.
73 int fStatus = -1; // Status of code of the last estimate
74 double fXMin = 0.; // Lower bound of the search interval.
75 double fXMax = 0.; // Upper bound of the search interval
76 double fRoot = 0.; // Current estimation of the function root.
77};
78} // namespace ROOT::Math
79
80#endif /* ROOT_Math_ModABRootFinder */
#define f(i)
Definition RSha256.hxx:104
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Definition IFunction.h:157
Interface for finding function roots of one-dimensional functions.
virtual bool SetFunction(const ROOT::Math::IGradFunction &, double)
Sets the function for algorithms using derivatives.
Class for finding the root of a one dimensional function using the ModAB algorithm.
const char * Name() const override
Return name of root finder algorithm ("ModABRootFinder").
const IGenFunction * fFunction
bool Solve(int maxIter=100, double absTol=1E-8, double relTol=1E-10) override
Returns the X value corresponding to the function value fy for (xmin<x<xmax).
bool SetFunction(const ROOT::Math::IGenFunction &f, double xlow, double xup) override
Sets the function for the rest of the algorithms.
int Iterations() const override
Return number of iteration used to find minimum.
int Status() const override
Returns status of last estimate.
double Root() const override
Returns root value.