public static double computeQpDelta(double slope, double prevSlope, double prevDelta) {
    { double delta = 0.0;

      if (prevDelta > Logic.$MODE_SWITCH$) {
        if (slope > 0.0) {
          delta = Logic.$LEARNING_RATE$ * slope;
        }
        if (slope > (Logic.$SHRINK_FACTOR$ * prevSlope)) {
          delta = delta + (Logic.$MAX_MOVEMENT$ * prevDelta);
        }
        else {
          delta = delta + ((slope / (prevSlope - slope)) * prevDelta);
        }
      }
      else if (prevDelta < (0.0 - Logic.$MODE_SWITCH$)) {
        if (slope < 0.0) {
          delta = Logic.$LEARNING_RATE$ * slope;
        }
        if (slope < (Logic.$SHRINK_FACTOR$ * prevSlope)) {
          delta = delta + (Logic.$MAX_MOVEMENT$ * prevDelta);
        }
        else {
          delta = delta + ((slope / (prevSlope - slope)) * prevDelta);
        }
      }
      else {
        delta = (Logic.$LEARNING_RATE$ * slope) + (Logic.$MOMENTUM_TERM$ * prevDelta);
      }
      return (delta);
    }
  }