@Override protected double solveImpl(final Ops.DoubleOp f,final double xAccuracy){
  double fxMid, froot, s, xMid, nextRoot;
  final double xAccuracy_=xAccuracy / 100.0;
  root=Constants.QL_MIN_POSITIVE_REAL;
  while (evaluationNumber <= getMaxEvaluations()) {
    xMid=0.5 * (xMin + xMax);
    fxMid=f.op(xMid);
    evaluationNumber++;
    s=Math.sqrt(fxMid * fxMid - fxMin * fxMax);
    if (s == 0.0)     return root;
    nextRoot=xMid + (xMid - xMin) * ((fxMin >= fxMax ? 1.0 : -1.0) * fxMid / s);
    if (Math.abs(nextRoot - root) <= xAccuracy_)     return root;
    root=nextRoot;
    froot=f.op(root);
    evaluationNumber++;
    if (froot == 0.0)     return root;
    if (sign(fxMid,froot) != fxMid) {
      xMin=xMid;
      fxMin=fxMid;
      xMax=root;
      fxMax=froot;
    }
 else     if (sign(fxMin,froot) != fxMin) {
      xMax=root;
      fxMax=froot;
    }
 else     if (sign(fxMax,froot) != fxMax) {
      xMin=root;
      fxMin=froot;
    }
 else     throw new LibraryException("internal error");
    if (Math.abs(xMax - xMin) <= xAccuracy_)     return root;
  }
  throw new ArithmeticException("maximum number of function evaluations exceeded");
}

@ Override protected double solveImpl ( final Ops . DoubleOp f , final double xAccuracy ) { double fxMid , froot , s , xMid , nextRoot ; final double xAccuracy_ = xAccuracy / 100.0 ; root = Constants . QL_MIN_POSITIVE_REAL ; while ( evaluationNumber <= getMaxEvaluations ( ) ) { xMid = 0.5 * ( xMin + xMax ) ; fxMid = f . op ( xMid ) ; evaluationNumber ++ ; s = Math . sqrt ( fxMid * fxMid - fxMin * fxMax ) ; if ( s == 0.0 ) return root ; nextRoot = xMid + ( xMid - xMin ) * ( ( fxMin >= fxMax ? 1.0 : - 1.0 ) * fxMid / s ) ; if ( Math . abs ( nextRoot - root ) <= xAccuracy_ ) return root ; root = nextRoot ; froot = f . op ( root ) ; evaluationNumber ++ ; if ( froot == 0.0 ) return root ; if ( sign ( fxMid , froot ) != fxMid ) { xMin = xMid ; fxMin = fxMid ; xMax = root ; fxMax = froot ; } else if ( sign ( fxMin , froot ) != fxMin ) { xMax = root ; fxMax = froot ; } else if ( sign ( fxMax , froot ) != fxMax ) { xMin = root ; fxMin = froot ; } else throw new LibraryException ( "internal error" ) ; if ( Math . abs ( xMax - xMin ) <= xAccuracy_ ) return root ; } throw new ArithmeticException ( "maximum number of function evaluations exceeded" ) ; }
computes the roots of a function by using the method due to ridder .
