public static void CF8(double[] x,double[] f,double[] c,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 N=2.0;
  double a=4.0;
  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++;
    }
  }
  f[0]=Math.cos(0.5 * PI * x[0]) * Math.cos(0.5 * PI * x[1]) + 2.0 * sum1 / (double)count1;
  f[1]=Math.cos(0.5 * PI * x[0]) * Math.sin(0.5 * PI * x[1]) + 2.0 * sum2 / (double)count2;
  f[2]=Math.sin(0.5 * PI * x[0]) + 2.0 * sum3 / (double)count3;
  c[0]=(f[0] * f[0] + f[1] * f[1]) / (1 - f[2] * f[2]) - a * Math.abs(Math.sin(N * PI * ((f[0] * f[0] - f[1] * f[1]) / (1 - f[2] * f[2]) + 1.0))) - 1.0;
}

public static void CF8 ( double [ ] x , double [ ] f , double [ ] c , 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 N = 2.0 ; double a = 4.0 ; 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 ++ ; } } f [ 0 ] = Math . cos ( 0.5 * PI * x [ 0 ] ) * Math . cos ( 0.5 * PI * x [ 1 ] ) + 2.0 * sum1 / ( double ) count1 ; f [ 1 ] = Math . cos ( 0.5 * PI * x [ 0 ] ) * Math . sin ( 0.5 * PI * x [ 1 ] ) + 2.0 * sum2 / ( double ) count2 ; f [ 2 ] = Math . sin ( 0.5 * PI * x [ 0 ] ) + 2.0 * sum3 / ( double ) count3 ; c [ 0 ] = ( f [ 0 ] * f [ 0 ] + f [ 1 ] * f [ 1 ] ) / ( 1 - f [ 2 ] * f [ 2 ] ) - a * Math . abs ( Math . sin ( N * PI * ( ( f [ 0 ] * f [ 0 ] - f [ 1 ] * f [ 1 ] ) / ( 1 - f [ 2 ] * f [ 2 ] ) + 1.0 ) ) ) - 1.0 ; }
evaluates the cf8 problem .
