31 char zerosec_borne_C[] =
"$Header: /cvsroot/Lorene/C++/Source/Non_class_members/Utilities/zerosec_borne.C,v 1.7 2014/10/13 08:53:32 j_novak Exp $" ;
69 double x1,
double x2,
double precis,
int nitermax,
int& niter) {
71 double f0_moins, f0, x0, x0_moins, dx, df , fnew, xnew;
75 f0_moins = f(x1, parf) ;
77 if ( f0*f0_moins > 0.) {
79 "WARNING: zerosec: there may not exist a zero of the function" 81 cout <<
" between x1 = " << x1 <<
" ( f(x1)=" << f0_moins <<
" )" << endl ;
82 cout <<
" and x2 = " << x2 <<
" ( f(x2)=" << f0 <<
" )" << endl ;
95 double swap = f0_moins ;
105 assert(df !=
double(0)) ;
106 xnew = (x0_moins*f0 - x0*f0_moins)/df ; ;
107 fnew = f(xnew, parf) ;
109 dx = x0_moins - xnew ;
119 if (niter > nitermax) {
128 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.