public static void UF2(double[] x,double[] f,int nx){
  int count1=0;
  int count2=0;
  double sum1=0.0;
  double sum2=0.0;
  double yj;
  for (int j=2; j <= nx; j++) {
    if (j % 2 == 0) {
      yj=x[j - 1] - 0.3 * x[0] * (x[0] * Math.cos(24.0 * PI * x[0] + 4.0 * j * PI / nx) + 2.0)* Math.sin(6.0 * PI * x[0] + j * PI / nx);
      sum2+=yj * yj;
      count2++;
    }
 else {
      yj=x[j - 1] - 0.3 * x[0] * (x[0] * Math.cos(24.0 * PI * x[0] + 4.0 * j * PI / nx) + 2.0)* Math.cos(6.0 * PI * x[0] + j * PI / nx);
      sum1+=yj * yj;
      count1++;
    }
  }
  f[0]=x[0] + 2.0 * sum1 / (double)count1;
  f[1]=1.0 - Math.sqrt(x[0]) + 2.0 * sum2 / (double)count2;
}

public static void UF2 ( double [ ] x , double [ ] f , int nx ) { int count1 = 0 ; int count2 = 0 ; double sum1 = 0.0 ; double sum2 = 0.0 ; double yj ; for ( int j = 2 ; j <= nx ; j ++ ) { if ( j % 2 == 0 ) { yj = x [ j - 1 ] - 0.3 * x [ 0 ] * ( x [ 0 ] * Math . cos ( 24.0 * PI * x [ 0 ] + 4.0 * j * PI / nx ) + 2.0 ) * Math . sin ( 6.0 * PI * x [ 0 ] + j * PI / nx ) ; sum2 += yj * yj ; count2 ++ ; } else { yj = x [ j - 1 ] - 0.3 * x [ 0 ] * ( x [ 0 ] * Math . cos ( 24.0 * PI * x [ 0 ] + 4.0 * j * PI / nx ) + 2.0 ) * Math . cos ( 6.0 * PI * x [ 0 ] + j * PI / nx ) ; sum1 += yj * yj ; count1 ++ ; } } f [ 0 ] = x [ 0 ] + 2.0 * sum1 / ( double ) count1 ; f [ 1 ] = 1.0 - Math . sqrt ( x [ 0 ] ) + 2.0 * sum2 / ( double ) count2 ; }
evaluates the uf2 problem .
