93 double x1,
double x2,
double precis,
int nitermax,
int& niter,
96 double f0_prec, f0, x0, x0_prec, dx, df ;
100 bool warning = false ;
102 f0_prec = f(x1, parf) ;
104 if ( f0*f0_prec > 0.) {
107 "WARNING: zerosec: there does not exist a unique zero of the function" 109 cout <<
" between x1 = " << x1 <<
" ( f(x1)=" << f0_prec <<
" )" << endl ;
110 cout <<
" and x2 = " << x2 <<
" ( f(x2)=" << f0 <<
" )" << endl ;
116 if ( fabs(f0) < fabs(f0_prec) ) {
123 double swap = f0_prec ;
133 assert(df !=
double(0)) ;
134 dx = (x0_prec - x0) * f0 / df ;
140 if (niter > nitermax) {
141 cout <<
"zerosec: Maximum number of iterations has been reached ! " 151 while ( ( fabs(dx) > precis ) && ( fabs(f0) > 1.e-15 ) ) ;
154 cout <<
" A zero may have been found at x0 = " << x0 << endl ;
double zerosec(double(*f)(double, const Param &), const Param &par, double a, double b, double precis, int nitermax, int &niter, bool abort=true)
Finding the zero a function.