72 double x1,
double x2,
double precis,
int nitermax,
int& niter) {
74 double f0_moins, f0, x0, x0_moins, dx, df , fnew, xnew;
78 f0_moins = f(x1, parf) ;
80 if ( f0*f0_moins > 0.) {
82 "WARNING: zerosec: there may not exist a zero of the function" 84 cout <<
" between x1 = " << x1 <<
" ( f(x1)=" << f0_moins <<
" )" << endl ;
85 cout <<
" and x2 = " << x2 <<
" ( f(x2)=" << f0 <<
" )" << endl ;
98 double swap = f0_moins ;
108 assert(df !=
double(0)) ;
109 xnew = (x0_moins*f0 - x0*f0_moins)/df ; ;
110 fnew = f(xnew, parf) ;
112 dx = x0_moins - xnew ;
122 if (niter > nitermax) {
131 while ( ( fabs(dx) > precis ) && ( fabs(fnew) > 1.e-15 ) ) ;
double zerosec_b(double(*f)(double, const Param &), const Param &par, double a, double b, double precis, int nitermax, int &niter)
Finding the zero a function on a bounded domain.