Program: 57330
Project: 57330
Buggy source:
/** 
 * {@inheritDoc} 
 */
public double integrate(final FirstOrderDifferentialEquations equations,final double t0,final double[] y0,final double t,final double[] y) throws MathUserException, IntegratorException {
  sanityChecks(equations,t0,y0,t,y);
  setEquations(equations);
  resetEvaluations();
  final boolean forward=t > t0;
  final int stages=c.length + 1;
  if (y != y0) {
    System.arraycopy(y0,0,y,0,y0.length);
  }
  final double[][] yDotK=new double[stages][];
  for (int i=0; i < stages; ++i) {
    yDotK[i]=new double[y0.length];
  }
  final double[] yTmp=new double[y0.length];
  final double[] yDotTmp=new double[y0.length];
  AbstractStepInterpolator interpolator;
  if (requiresDenseOutput()) {
    final RungeKuttaStepInterpolator rki=(RungeKuttaStepInterpolator)prototype.copy();
    rki.reinitialize(this,yTmp,yDotK,forward);
    interpolator=rki;
  }
 else {
    interpolator=new DummyStepInterpolator(yTmp,yDotK[stages - 1],forward);
  }
  interpolator.storeTime(t0);
  stepStart=t0;
  stepSize=forward ? step : -step;
  for (  StepHandler handler : stepHandlers) {
    handler.reset();
  }
  statesInitialized=false;
  isLastStep=false;
  do {
    interpolator.shift();
    computeDerivatives(stepStart,y,yDotK[0]);
    for (int k=1; k < stages; ++k) {
      for (int j=0; j < y0.length; ++j) {
        double sum=a[k - 1][0] * yDotK[0][j];
        for (int l=1; l < k; ++l) {
          sum+=a[k - 1][l] * yDotK[l][j];
        }
        yTmp[j]=y[j] + stepSize * sum;
      }
      computeDerivatives(stepStart + c[k - 1] * stepSize,yTmp,yDotK[k]);
    }
    for (int j=0; j < y0.length; ++j) {
      double sum=b[0] * yDotK[0][j];
      for (int l=1; l < stages; ++l) {
        sum+=b[l] * yDotK[l][j];
      }
      yTmp[j]=y[j] + stepSize * sum;
    }
    interpolator.storeTime(stepStart + stepSize);
    System.arraycopy(yTmp,0,y,0,y0.length);
    System.arraycopy(yDotK[stages - 1],0,yDotTmp,0,y0.length);
    stepStart=acceptStep(interpolator,y,yDotTmp,t);
    if (!isLastStep) {
      interpolator.storeTime(stepStart);
      final double nextT=stepStart + stepSize;
      final boolean nextIsLast=forward ? (nextT >= t) : (nextT <= t);
      if (nextIsLast) {
        stepSize=t - stepStart;
      }
    }
  }
 while (!isLastStep);
  final double stopTime=stepStart;
  stepStart=Double.NaN;
  stepSize=Double.NaN;
  return stopTime;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
public double integrate(final FirstOrderDifferentialEquations equations,final double t0,final double[] y0,final double t,final double[] y) throws MathUserException, IntegratorException {
  sanityChecks(equations,t0,y0,t,y);
  setEquations(equations);
  resetEvaluations();
  final boolean forward=t > t0;
  final int stages=c.length + 1;
  if (y != y0) {
    System.arraycopy(y0,0,y,0,y0.length);
  }
  final double[][] yDotK=new double[stages][];
  for (int i=0; i < stages; ++i) {
    yDotK[i]=new double[y0.length];
  }
  final double[] yTmp=new double[y0.length];
  final double[] yDotTmp=new double[y0.length];
  AbstractStepInterpolator interpolator;
  if (requiresDenseOutput()) {
    final RungeKuttaStepInterpolator rki=(RungeKuttaStepInterpolator)prototype.copy();
    rki.reinitialize(this,yTmp,yDotK,forward);
    interpolator=rki;
  }
 else {
    interpolator=new DummyStepInterpolator(yTmp,yDotK[stages - 1],forward);
  }
  interpolator.storeTime(t0);
  stepStart=t0;
  stepSize=forward ? step : -step;
  for (  StepHandler handler : stepHandlers) {
    handler.reset();
  }
  setStateInitialized(false);
  isLastStep=false;
  do {
    interpolator.shift();
    computeDerivatives(stepStart,y,yDotK[0]);
    for (int k=1; k < stages; ++k) {
      for (int j=0; j < y0.length; ++j) {
        double sum=a[k - 1][0] * yDotK[0][j];
        for (int l=1; l < k; ++l) {
          sum+=a[k - 1][l] * yDotK[l][j];
        }
        yTmp[j]=y[j] + stepSize * sum;
      }
      computeDerivatives(stepStart + c[k - 1] * stepSize,yTmp,yDotK[k]);
    }
    for (int j=0; j < y0.length; ++j) {
      double sum=b[0] * yDotK[0][j];
      for (int l=1; l < stages; ++l) {
        sum+=b[l] * yDotK[l][j];
      }
      yTmp[j]=y[j] + stepSize * sum;
    }
    interpolator.storeTime(stepStart + stepSize);
    System.arraycopy(yTmp,0,y,0,y0.length);
    System.arraycopy(yDotK[stages - 1],0,yDotTmp,0,y0.length);
    stepStart=acceptStep(interpolator,y,yDotTmp,t);
    if (!isLastStep) {
      interpolator.storeTime(stepStart);
      final double nextT=stepStart + stepSize;
      final boolean nextIsLast=forward ? (nextT >= t) : (nextT <= t);
      if (nextIsLast) {
        stepSize=t - stepStart;
      }
    }
  }
 while (!isLastStep);
  final double stopTime=stepStart;
  stepStart=Double.NaN;
  stepSize=Double.NaN;
  return stopTime;
}