Brent's method

From stats++ wiki
Jump to: navigation, search

stats++

In stats++, Brent's method is accomplished with the Brent class:

class Brent : public BracketMethod
{
 
public:
 
    double tol;
    int iter_max;
 
 
    Brent();
    ~Brent();
 
    std::tuple<int,
               double,
               double> minimize(std::function<double(const double)> f,
                                double x1,
                                double x2);
 
};

In code, it functions as follows:

Brent brent;
 
int info;
double x = ...;
double fx;
std::tie(info, x, fx) = cg.minimize(f, x);

Example

IGNORE