private boolean findRoot(final ODEStateInterpolator interpolator,final double ta,final double ga,final double tb,final double gb){
  check(ga == 0.0 || gb == 0.0 || (ga > 0.0 && gb < 0.0) || (ga < 0.0 && gb > 0.0));
  final UnivariateFunction f=null;
  double beforeRootT=Double.NaN, beforeRootG=Double.NaN;
  double afterRootT=ta, afterRootG=0.0;
  if (ta == tb) {
    beforeRootT=ta;
    beforeRootG=ga;
    afterRootT=shiftedBy(beforeRootT,convergence);
    afterRootG=f.value(afterRootT);
  }
 else   if (ga != 0.0 && gb == 0.0) {
    beforeRootT=tb;
    beforeRootG=gb;
    afterRootT=shiftedBy(beforeRootT,convergence);
    afterRootG=f.value(afterRootT);
  }
 else   if (ga != 0.0) {
    final double newGa=f.value(ta);
    if (ga > 0 != newGa > 0) {
      beforeRootT=ta;
      beforeRootG=newGa;
      afterRootT=minTime(shiftedBy(beforeRootT,convergence),tb);
      afterRootG=f.value(afterRootT);
    }
  }
  double loopT=ta, loopG=ga;
  while ((afterRootG == 0.0 || afterRootG > 0.0 == g0Positive) && strictlyAfter(afterRootT,tb)) {
    if (loopG == 0.0) {
      beforeRootT=loopT;
      beforeRootG=loopG;
      afterRootT=minTime(shiftedBy(beforeRootT,convergence),tb);
      afterRootG=f.value(afterRootT);
    }
 else {
      if (forward) {
        final Interval interval=solver.solveInterval(maxIterationCount,f,loopT,tb);
        beforeRootT=interval.getLeftAbscissa();
        beforeRootG=interval.getLeftValue();
        afterRootT=interval.getRightAbscissa();
        afterRootG=interval.getRightValue();
      }
 else {
        final Interval interval=solver.solveInterval(maxIterationCount,f,tb,loopT);
        beforeRootT=interval.getRightAbscissa();
        beforeRootG=interval.getRightValue();
        afterRootT=interval.getLeftAbscissa();
        afterRootG=interval.getLeftValue();
      }
    }
    if (beforeRootT == afterRootT) {
      afterRootT=nextAfter(afterRootT);
      afterRootG=f.value(afterRootT);
    }
    check((forward && afterRootT > beforeRootT) || (!forward && afterRootT < beforeRootT));
    loopT=afterRootT;
    loopG=afterRootG;
  }
  if (afterRootG == 0.0 || afterRootG > 0.0 == g0Positive) {
    return false;
  }
 else {
    check(!Double.isNaN(beforeRootT) && !Double.isNaN(beforeRootG));
    increasing=!g0Positive;
    pendingEventTime=beforeRootT;
    stopTime=beforeRootG == 0.0 ? beforeRootT : afterRootT;
    pendingEvent=true;
    afterEvent=afterRootT;
    afterG=afterRootG;
    check(afterG > 0 == increasing);
    check(increasing == gb >= ga);
    return true;
  }
}

private boolean findRoot ( final ODEStateInterpolator interpolator , final double ta , final double ga , final double tb , final double gb ) { check ( ga == 0.0 || gb == 0.0 || ( ga > 0.0 && gb < 0.0 ) || ( ga < 0.0 && gb > 0.0 ) ) ; final UnivariateFunction f = null ; double beforeRootT = Double . NaN , beforeRootG = Double . NaN ; double afterRootT = ta , afterRootG = 0.0 ; if ( ta == tb ) { beforeRootT = ta ; beforeRootG = ga ; afterRootT = shiftedBy ( beforeRootT , convergence ) ; afterRootG = f . value ( afterRootT ) ; } else if ( ga != 0.0 && gb == 0.0 ) { beforeRootT = tb ; beforeRootG = gb ; afterRootT = shiftedBy ( beforeRootT , convergence ) ; afterRootG = f . value ( afterRootT ) ; } else if ( ga != 0.0 ) { final double newGa = f . value ( ta ) ; if ( ga > 0 != newGa > 0 ) { beforeRootT = ta ; beforeRootG = newGa ; afterRootT = minTime ( shiftedBy ( beforeRootT , convergence ) , tb ) ; afterRootG = f . value ( afterRootT ) ; } } double loopT = ta , loopG = ga ; while ( ( afterRootG == 0.0 || afterRootG > 0.0 == g0Positive ) && strictlyAfter ( afterRootT , tb ) ) { if ( loopG == 0.0 ) { beforeRootT = loopT ; beforeRootG = loopG ; afterRootT = minTime ( shiftedBy ( beforeRootT , convergence ) , tb ) ; afterRootG = f . value ( afterRootT ) ; } else { if ( forward ) { final Interval interval = solver . solveInterval ( maxIterationCount , f , loopT , tb ) ; beforeRootT = interval . getLeftAbscissa ( ) ; beforeRootG = interval . getLeftValue ( ) ; afterRootT = interval . getRightAbscissa ( ) ; afterRootG = interval . getRightValue ( ) ; } else { final Interval interval = solver . solveInterval ( maxIterationCount , f , tb , loopT ) ; beforeRootT = interval . getRightAbscissa ( ) ; beforeRootG = interval . getRightValue ( ) ; afterRootT = interval . getLeftAbscissa ( ) ; afterRootG = interval . getLeftValue ( ) ; } } if ( beforeRootT == afterRootT ) { afterRootT = nextAfter ( afterRootT ) ; afterRootG = f . value ( afterRootT ) ; } check ( ( forward && afterRootT > beforeRootT ) || ( ! forward && afterRootT < beforeRootT ) ) ; loopT = afterRootT ; loopG = afterRootG ; } if ( afterRootG == 0.0 || afterRootG > 0.0 == g0Positive ) { return false ; } else { check ( ! Double . isNaN ( beforeRootT ) && ! Double . isNaN ( beforeRootG ) ) ; increasing = ! g0Positive ; pendingEventTime = beforeRootT ; stopTime = beforeRootG == 0.0 ? beforeRootT : afterRootT ; pendingEvent = true ; afterEvent = afterRootT ; afterG = afterRootG ; check ( afterG > 0 == increasing ) ; check ( increasing == gb >= ga ) ; return true ; } }
find a root in a bracketing interval . < p > when calling this method one of the following must be true . either ga = = 0 , gb = = 0 , ( ga < 0 and gb > 0 ) , or ( ga > 0 and gb < 0 ) .
