code: static public double ackley(double[] x) {
  
      double sum1 = 0.0;
      double sum2 = 0.0;
  
      for (int i = 0; i < x.length; i++) {
        sum1 += (x[i] * x[i]);
        sum2 += (Math.cos(PIx2 * x[i]));
      }
  
      return (-20.0 * Math.exp(-0.2 * Math.sqrt(sum1 / ((double) x.length))) - Math
        .exp(sum2 / ((double) x.length)) + 20.0 + Math.E);
    }
docs: Ackley's function