Buggy code:
public class EventState implements Serializable { private static final long serialVersionUID = - 216176055159247559L ; private final EventHandler handler ; private final double maxCheckInterval ; private final double convergence ; private final int maxIterationCount ; private double t0 ; private double g0 ; private boolean g0Positive ; private boolean pendingEvent ; private double pendingEventTime ; private double previousEventTime ; private boolean increasing ; private int nextAction ; public EventState ( final EventHandler handler , final double maxCheckInterval , final double convergence , final int maxIterationCount ) { } public EventHandler getEventHandler ( ) { } public double getMaxCheckInterval ( ) { } public double getConvergence ( ) { } public int getMaxIterationCount ( ) { } public void reinitializeBegin ( final double t0 , final double [ ] y0 ) throws EventException { } public boolean evaluateStep ( final StepInterpolator interpolator ) throws ConvergenceException , DerivativeException , EventException { try { final double t1 = interpolator . getCurrentTime ( ) ; final int n = Math . max ( 1 , ( ( int ) ( Math . ceil ( ( ( Math . abs ( ( t1 - ( t0 ) ) ) ) // ( maxCheckInterval ) ) ) ) ) ) ; final double h = ( t1 - ( t0 ) ) // n ; double ta = t0 ; double ga = g0 ; double tb = ( t0 ) + ( t1 > ( t0 ) ? convergence : - ( convergence ) ) ; for ( int i = 0 ; i < n ; ++ i ) { tb += h ; interpolator . setInterpolatedTime ( tb ) ; final double gb = handler . g ( tb , interpolator . getInterpolatedState ( ) ) ; if ( ( g0Positive ) ^ ( gb >= 0 ) ) { increasing = gb >= ga ; final UnivariateRealSolver solver = new BrentSolver ( new UnivariateRealFunction ( ) { public double value ( final double t ) throws FunctionEvaluationException { try { interpolator . setInterpolatedTime ( t ) ; return handler . g ( t , interpolator . getInterpolatedState ( ) ) ; } catch ( DerivativeException e ) { throw new FunctionEvaluationException ( t , e ) ; } catch ( EventException e ) { throw new FunctionEvaluationException ( t , e ) ; } } } ) ; solver . setAbsoluteAccuracy ( convergence ) ; solver . setMaximalIterationCount ( maxIterationCount ) ; <START_BUG> final double root = solver . solve ( ta , tb ) ; <END_BUG> if ( ( Double . isNaN ( previousEventTime ) ) || ( ( Math . abs ( ( ( previousEventTime ) - root ) ) ) > ( convergence ) ) ) { pendingEventTime = root ; if ( ( pendingEvent ) && ( ( Math . abs ( ( t1 - ( pendingEventTime ) ) ) ) <= ( convergence ) ) ) { return false ; } pendingEvent = true ; return true ; } } else { ta = tb ; ga = gb ; } } pendingEvent = false ; pendingEventTime = Double . NaN ; return false ; } catch ( FunctionEvaluationException e ) { final Throwable cause = e . getCause ( ) ; if ( ( cause != null ) && ( cause instanceof DerivativeException ) ) { throw ( ( DerivativeException ) ( cause ) ) ; } else if ( ( cause != null ) && ( cause instanceof EventException ) ) { throw ( ( EventException ) ( cause ) ) ; } throw new EventException ( e ) ; } } public double getEventTime ( ) { } public void stepAccepted ( final double t , final double [ ] y ) throws EventException { } public boolean stop ( ) { } public boolean reset ( final double t , final double [ ] y ) throws EventException { } }

Fix:
final double root = ( ta <= tb ) ? solver . solve ( ta , tb ) : solver . solve ( tb , ta ) ;