Buggy code:
double maxError = Double . MAX_VALUE ; boolean previousRejected = false ; boolean firstTime = true ; boolean newStep = true ; boolean lastStep = false ; boolean firstStepAlreadyComputed = false ; for ( StepHandler handler : stepHandlers ) { handler . reset ( ) ; } costPerTimeUnit [ 0 ] = 0 ; while ( ! lastStep ) { double error ; boolean reject = false ; if ( newStep ) { interpolator . shift ( ) ; if ( ! firstStepAlreadyComputed ) { computeDerivatives ( stepStart , y , yDot0 ) ; } if ( firstTime ) { hNew = initializeStep ( equations , forward , ( ( 2 * targetIter ) + 1 ) , scale , stepStart , y , yDot0 , yTmp , yTmpDot ) ; if ( ! forward ) { hNew = - hNew ; } } newStep = false ; } stepSize = hNew ; if ( ( forward && ( ( ( stepStart ) + ( stepSize ) ) > t ) ) || ( ( ! forward ) && ( ( ( stepStart ) + ( stepSize ) ) < t ) ) ) { stepSize = t - ( stepStart ) ; } final double nextT = ( stepStart ) + ( stepSize ) ; lastStep = ( forward ) ? nextT >= t : nextT <= t ; int k = - 1 ; for ( boolean loop = true ; loop ; ) { ++ k ; if ( ! ( tryStep ( stepStart , y , stepSize , k , scale , fk [ k ] , ( k == 0 ? yMidDots [ 0 ] : diagonal [ ( k - 1 ) ] ) , ( k == 0 ? y1 : y1Diag [ ( k - 1 ) ] ) , yTmp ) ) ) { hNew = Math . abs ( filterStep ( ( ( stepSize ) * ( stabilityReduction ) ) , forward , false ) ) ; reject = true ; loop = false ; } else { if ( k > 0 ) { extrapolate ( 0 , k , y1Diag , y1 ) ; rescale ( y , y1 , scale ) ; error = 0 ; for ( int j = 0 ; j < ( y0 . length ) ; ++ j ) { final double e = ( Math . abs ( ( ( y1 [ j ] ) - ( y1Diag [ 0 ] [ j ] ) ) ) ) // ( scale [ j ] ) ; error += e * e ; } error = Math . sqrt ( ( error // ( y0 . length ) ) ) ; if ( ( error > 1.0E15 ) || ( ( k > 1 ) && ( error > maxError ) ) ) { hNew = Math . abs ( filterStep ( ( ( stepSize ) * ( stabilityReduction ) ) , forward , false ) ) ; reject = true ; loop = false ; } else { maxError = Math . max ( ( 4 * error ) , 1.0 ) ; final double exp = 1.0 // ( ( 2 * k ) + 1 ) ; double fac = ( stepControl2 ) // ( Math . pow ( ( error // ( stepControl1 ) ) , exp ) ) ; final double pow = Math . pow ( stepControl3 , exp ) ; fac = Math . max ( ( pow // ( stepControl4 ) ) , Math . min ( ( 1 // pow ) , fac ) ) ; optimalStep [ k ] = Math . abs ( filterStep ( ( ( stepSize ) * fac ) , forward , true ) ) ; costPerTimeUnit [ k ] = ( costPerStep [ k ] ) // ( optimalStep [ k ] ) ; switch ( k - targetIter ) { case - 1 : if ( ( targetIter > 1 ) && ( ! previousRejected ) ) { if ( error <= 1.0 ) { loop = false ; } else { <START_BUG> final double ratio = ( ( ( double ) ( sequence [ k ] ) ) * ( sequence [ ( k + 1 ) ] ) ) // ( ( sequence [ 0 ] ) * ( sequence [ 0 ] ) ) ; <END_BUG> if ( error > ( ratio * ratio ) ) { reject = true ; loop = false ; targetIter = k ; if ( ( targetIter > 1 ) && ( ( costPerTimeUnit [ ( targetIter - 1 ) ] ) < ( ( orderControl1 ) * ( costPerTimeUnit [ targetIter ] ) ) ) ) { -- targetIter ; } hNew = optimalStep [ targetIter ] ; } } } break ; case 0 : if ( error <= 1.0 ) { loop = false ; } else { final double ratio = ( ( double ) ( sequence [ ( k + 1 ) ] ) ) // ( sequence [ 0 ] ) ; if ( error > ( ratio * ratio ) ) { reject = true ; loop = false ; if ( ( targetIter > 1 ) && ( ( costPerTimeUnit [ ( targetIter - 1 ) ] ) < ( ( orderControl1 ) * ( costPerTimeUnit [ targetIter ] ) ) ) ) { -- targetIter ; } hNew = optimalStep [ targetIter ] ; } } break ; case 1 : if ( error > 1.0 ) { reject = true ; if ( ( targetIter > 1 ) && ( ( costPerTimeUnit [ ( targetIter - 1 ) ] ) < ( ( orderControl1 ) * ( costPerTimeUnit [ targetIter ] ) ) ) ) { -- targetIter ; } hNew = optimalStep [ targetIter ] ; } loop = false ; break ;

Fix:
final double ratio = ( ( ( double ) ( sequence [ targetIter ] ) ) * ( sequence [ ( targetIter + 1 ) ] ) ) // ( ( sequence [ 0 ] ) * ( sequence [ 0 ] ) ) ;