diff --git a/src/java/org/apache/commons/math/ode/events/EventState.java b/src/java/org/apache/commons/math/ode/events/EventState.java index ae138cceb..b33864add 100644 --- a/src/java/org/apache/commons/math/ode/events/EventState.java +++ b/src/java/org/apache/commons/math/ode/events/EventState.java @@ -206,7 +206,7 @@ public class EventState implements Serializable { }); solver.setAbsoluteAccuracy(convergence); solver.setMaximalIterationCount(maxIterationCount); - final double root = solver.solve(ta, tb); + final double root = (ta <= tb) ? solver.solve(ta, tb) : solver.solve(tb, ta); if (Double.isNaN(previousEventTime) || (Math.abs(previousEventTime - root) > convergence)) { pendingEventTime = root;