7 bool is_effectively_zero(
double x)
16 const int max_iter = 10;
19 double fl = f.
eval(xl);
22 double fr = f.
eval(xr);
27 throw UniversalError(
"Error in bisection::find_upper_bracket. Max number of iterations exceeded");
39 const int max_iter = 100;
43 double fl = f.
eval(xl);
44 if(is_effectively_zero(fl))
47 double fr = f.
eval(xr);
48 if(is_effectively_zero(fr))
60 while(fabs(xl-xr)>tol){
61 double xm = 0.5*(xl+xr);
62 double fm = f.
eval(xm);
63 if(is_effectively_zero(fm))
73 throw UniversalError(
"Error in Bisection: Maximum number of iterations exceeded");
Container for error reports.
double find_upper_bracket(Func1Var const &f, double xl)
Finds an upper limit to an equation.
virtual double eval(double x) const =0
Evaluates the function.
double bisection(Func1Var const &f, double xl, double xr, double tol=1e-6)
Solves a monotonous transcendental equation using the bisection method.
Scalar function of a single variable.
Solution of transcendental equations with a single variable using the bisection method.
void AddEntry(std::string const &field, double value)
Adds an entry to the list.
A class for storing error and debug information.