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

public static void CF3 ( double [ ] x , double [ ] f , double [ ] c , int nx ) { int count1 = 0 ; int count2 = 0 ; double sum1 = 0.0 ; double sum2 = 0.0 ; double prod1 = 1.0 ; double prod2 = 1.0 ; double yj ; double pj ; double N = 2.0 ; double a = 1.0 ; for ( int j = 2 ; j <= nx ; j ++ ) { yj = x [ j - 1 ] - Math . sin ( 6.0 * PI * x [ 0 ] + j * PI / nx ) ; pj = Math . cos ( 20.0 * yj * PI / Math . sqrt ( j + 0.0 ) ) ; if ( j % 2 == 0 ) { sum2 += yj * yj ; prod2 *= pj ; count2 ++ ; } else { sum1 += yj * yj ; prod1 *= pj ; count1 ++ ; } } f [ 0 ] = x [ 0 ] + 2.0 * ( 4.0 * sum1 - 2.0 * prod1 + 2.0 ) / ( double ) count1 ; f [ 1 ] = 1.0 - x [ 0 ] * x [ 0 ] + 2.0 * ( 4.0 * sum2 - 2.0 * prod2 + 2.0 ) / ( double ) count2 ; c [ 0 ] = f [ 1 ] + f [ 0 ] * f [ 0 ] - a * Math . sin ( N * PI * ( f [ 0 ] * f [ 0 ] - f [ 1 ] + 1.0 ) ) - 1.0 ; }
evaluates the cf3 problem .
