public static void CF5(double[] x,double[] f,double[] c,int nx){
  double sum1=0.0;
  double sum2=0.0;
  double yj;
  for (int j=2; j <= nx; j++) {
    if (j % 2 == 1) {
      yj=x[j - 1] - 0.8 * x[0] * Math.cos(6.0 * PI * x[0] + j * PI / nx);
      sum1+=2.0 * yj * yj - Math.cos(4.0 * PI * yj) + 1.0;
    }
 else {
      yj=x[j - 1] - 0.8 * x[0] * Math.sin(6.0 * PI * x[0] + j * PI / nx);
      if (j == 2) {
        sum2+=yj < 1.5 - 0.75 * Math.sqrt(2.0) ? Math.abs(yj) : (0.125 + (yj - 1) * (yj - 1));
      }
 else {
        sum2+=2.0 * yj * yj - Math.cos(4.0 * PI * yj) + 1.0;
      }
    }
  }
  f[0]=x[0] + sum1;
  f[1]=1.0 - x[0] + sum2;
  c[0]=x[1] - 0.8 * x[0] * Math.sin(6.0 * x[0] * PI + 2.0 * PI / nx) - 0.5 * x[0] + 0.25;
}

public static void CF5 ( double [ ] x , double [ ] f , double [ ] c , int nx ) { double sum1 = 0.0 ; double sum2 = 0.0 ; double yj ; for ( int j = 2 ; j <= nx ; j ++ ) { if ( j % 2 == 1 ) { yj = x [ j - 1 ] - 0.8 * x [ 0 ] * Math . cos ( 6.0 * PI * x [ 0 ] + j * PI / nx ) ; sum1 += 2.0 * yj * yj - Math . cos ( 4.0 * PI * yj ) + 1.0 ; } else { yj = x [ j - 1 ] - 0.8 * x [ 0 ] * Math . sin ( 6.0 * PI * x [ 0 ] + j * PI / nx ) ; if ( j == 2 ) { sum2 += yj < 1.5 - 0.75 * Math . sqrt ( 2.0 ) ? Math . abs ( yj ) : ( 0.125 + ( yj - 1 ) * ( yj - 1 ) ) ; } else { sum2 += 2.0 * yj * yj - Math . cos ( 4.0 * PI * yj ) + 1.0 ; } } } f [ 0 ] = x [ 0 ] + sum1 ; f [ 1 ] = 1.0 - x [ 0 ] + sum2 ; c [ 0 ] = x [ 1 ] - 0.8 * x [ 0 ] * Math . sin ( 6.0 * x [ 0 ] * PI + 2.0 * PI / nx ) - 0.5 * x [ 0 ] + 0.25 ; }
evaluates the cf5 problem .
