Class root_bkt_cern (o2scl)

O2scl : Class List

template<class func_t = funct>
class root_bkt_cern : public o2scl::root_bkt<funct>

One-dimensional root-finding routine (CERNLIB)

This class attempts to find \( x_1 \) and \( x_2 \) in \( [a,b] \) such that:

  • \( f(x_1) f(x_2) \leq 0 \),

  • \( |f(x_1)| \leq|f(x_2)| \), and

  • \( | x_1-x_2| \leq 2~\mathrm{tol\_abs}~(1+|x_0|) \).

The function solve_bkt() requires inputs x1 and x2 such that the first condition, \( f(x_1) f(x_2) \leq 0 \), already holds.

The variable root::tol_abs defaults to \( 10^{-8} \) and root::ntrial defaults to 200.

The function solve_bkt() will call the error handler if the root is not initially bracketed. If root::err_nonconv is true (as it is by default), then the error handler will also be called if the number function evaluations is greater than root::ntrial.

After a call to solve_bkt(), root::last_ntrial contains the total number of iterations which were used

See the One-dimensional solvers section of the User’s guide for general information about O2scl solvers.

This class is Based on the CERNLIB routines RZEROX and DZEROX, which was based on [Bus75] and was documented at http://wwwasdoc.web.cern.ch/wwwasdoc/shortwrupsdir/c200/top.html

Public Functions

inline root_bkt_cern()
inline int set_mode(int m)

Set mode of solution (1 or 2)

  • 1 should be used for simple functions where the cost is inexpensive in comparison to one iteration of solve_bkt(), or functions which have a pole near the root (this is the default).

  • 2 should be used for more time-consuming functions.

If an integer other than 1 or 2 is specified, the error handler is called.

inline virtual const char *type()

Return the type, "root_bkt_cern".

inline virtual int solve_bkt(double &x1, double x2, func_t &func)

Solve func in region \( x_1<x<x_2 \) returning \( x_1 \).

Protected Functions

inline double sign(double a, double b)

FORTRAN-like function for sign.

Protected Attributes

int mode

Internal storage for the mode.

This internal variable is actually defined to be smaller by 1 than the “mode” as it is defined in the CERNLIB documentation in order to avoid needless subtraction in solve_bkt().