code: private double handleCase3() {
  		double stpf;
  		// use cubic interpolation only if it is safe
  		double stpc = SearchInterpolate.cubicSafe(fp, gp, stp, fx, gx, stx, stmin, stmax);
  		double stpq = SearchInterpolate.quadratic2(gp,stp,gx,stx);
  
  		if( bracket ) {
  			// Use which ever step is closer to stp
  			if( Math.abs(stpc-stp) < Math.abs(stpq-stp)){
  				stpf = stpc;
  			} else {
  				stpf = stpq;
  			}
  			if( stp > stx ) {
  				stpf = Math.min(stp+p66*(sty-stp),stpf);
  			} else {
  				stpf = Math.max(stp+p66*(sty-stp),stpf);
  			}
  		} else {
  			// because a bracket has not been found, take whichever step is farther from stp
  			if( Math.abs(stpc-stp) > Math.abs(stpq-stp)) {
  				stpf = stpc;
  			} else {
  				stpf = stpq;
  			}
  			stpf = Math.min(stmax,stpf); // this really is stmax/stmin and not stpmax/stpmin
  			stpf = Math.max(stmin,stpf); // In the for tran can stmax and stmin is passed in for stpmax and stpmin
  		}
  		return stpf;
  	}
docs: The derivative at stp has a smaller magnitude than at stx and is likely to be closer to the minimum.  However
  there are special cases that need to be dealt with here.
  
  @return The new step.