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

public static void UF9 ( double [ ] x , double [ ] f , int nx ) { int count1 = 0 ; int count2 = 0 ; int count3 = 0 ; double sum1 = 0.0 ; double sum2 = 0.0 ; double sum3 = 0.0 ; double yj ; double E = 0.1 ; for ( int j = 3 ; j <= nx ; j ++ ) { yj = x [ j - 1 ] - 2.0 * x [ 1 ] * Math . sin ( 2.0 * PI * x [ 0 ] + j * PI / nx ) ; if ( j % 3 == 1 ) { sum1 += yj * yj ; count1 ++ ; } else if ( j % 3 == 2 ) { sum2 += yj * yj ; count2 ++ ; } else { sum3 += yj * yj ; count3 ++ ; } } yj = ( 1.0 + E ) * ( 1.0 - 4.0 * ( 2.0 * x [ 0 ] - 1.0 ) * ( 2.0 * x [ 0 ] - 1.0 ) ) ; if ( yj < 0.0 ) { yj = 0.0 ; } f [ 0 ] = 0.5 * ( yj + 2 * x [ 0 ] ) * x [ 1 ] + 2.0 * sum1 / ( double ) count1 ; f [ 1 ] = 0.5 * ( yj - 2 * x [ 0 ] + 2.0 ) * x [ 1 ] + 2.0 * sum2 / ( double ) count2 ; f [ 2 ] = 1.0 - x [ 1 ] + 2.0 * sum3 / ( double ) count3 ; }
evaluates the uf9 problem .
