Function bracketing

From stats++ wiki
Jump to: navigation, search

stats++

In stats++, a function can be bracketed using the BracketMethod class:

class BracketMethod
{
 
public:
 
    double max_stp;
 
 
    BracketMethod();
    ~BracketMethod();
 
    std::tuple<double,
               double,
               double,
               double,
               double,
               double> bracket(std::function<double(const double)> f,
                               double x1,
                               double x2);
 
};

In code, it functions as follows:

BracketMethod bm;
 
double x1 = ...;
double x2 = ...;
double x3;
double f1;
double f2;
double f3;
std::tie(x1, x2, x3, f1, f2, f3) = bm.bracket(f, x1, x2);

Example

IGNORE