public static void UF5(double[] x,double[] f,int nx){
  int count1=0;
  int count2=0;
  double sum1=0.0;
  double sum2=0.0;
  double yj;
  double hj;
  double N=10.0;
  double E=0.1;
  for (int j=2; j <= nx; j++) {
    yj=x[j - 1] - Math.sin(6.0 * PI * x[0] + j * PI / nx);
    hj=2.0 * yj * yj - Math.cos(4.0 * PI * yj) + 1.0;
    if (j % 2 == 0) {
      sum2+=hj;
      count2++;
    }
 else {
      sum1+=hj;
      count1++;
    }
  }
  hj=(0.5 / N + E) * Math.abs(Math.sin(2.0 * N * PI* x[0]));
  f[0]=x[0] + hj + 2.0 * sum1 / (double)count1;
  f[1]=1.0 - x[0] + hj + 2.0 * sum2 / (double)count2;
}

public static void UF5 ( double [ ] x , double [ ] f , int nx ) { int count1 = 0 ; int count2 = 0 ; double sum1 = 0.0 ; double sum2 = 0.0 ; double yj ; double hj ; double N = 10.0 ; double E = 0.1 ; for ( int j = 2 ; j <= nx ; j ++ ) { yj = x [ j - 1 ] - Math . sin ( 6.0 * PI * x [ 0 ] + j * PI / nx ) ; hj = 2.0 * yj * yj - Math . cos ( 4.0 * PI * yj ) + 1.0 ; if ( j % 2 == 0 ) { sum2 += hj ; count2 ++ ; } else { sum1 += hj ; count1 ++ ; } } hj = ( 0.5 / N + E ) * Math . abs ( Math . sin ( 2.0 * N * PI * x [ 0 ] ) ) ; f [ 0 ] = x [ 0 ] + hj + 2.0 * sum1 / ( double ) count1 ; f [ 1 ] = 1.0 - x [ 0 ] + hj + 2.0 * sum2 / ( double ) count2 ; }
evaluates the uf5 problem .
