* -------------------------------------------------------------
*
*                            TEST FUNCTIONS 
*
*   
*                            Neculai Andrei
*                 Research Institute for Informatics
*            Center for Advanced Modeling and Optimization
*             8-10, Averescu Avenue, Bucharest 1, Romania
*                        E-mail: nandrei@ici.ro   
*
*---------------------------------------------------------------                                                  
* Date created  (first version): October   4, 2004.            
* Date modified (last version) : November 17, 2004.
*---------------------------------------------------------------
*


cF1                        Extended Freudenstein & Roth
*
*                       Initial Point: [0.5, -2, ...,0.5, -2].
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)  
      real*8 t1,t2
*      
      f = 0.d0
      n1=n/2 
      j=1         
*      
      do i=1,n1 
        t1=-13.d0+x(2*i-1)+5.d0*x(2*i)*x(2*i)-x(2*i)**3-2.d0*x(2*i) 
        t2=-29.d0+x(2*i-1)+x(2*i)**3+x(2*i)**2-14.d0*x(2*i)   
        
        f = f + t1*t1 + t2*t2

*-- Gradient
        
        g(j)  =2.d0*(t1+t2)   
        g(j+1)=2.d0*t1*(10.d0*x(2*i)-3.d0*x(2*i)*x(2*i)-2.d0) +
     *            2.d0*t2*(3.d0*x(2*i)*x(2*i)+2.d0*x(2*i)-14.d0)   
        j=j+2        
      end do   
      
      return
      end
c********************************************************************
             
             




cF2                          Extended Trigonometric Function
*
*                          Initial Point: [0.2, 0.2, ....,0.2].

      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)
      real*8 s, temp(11000)
      
      s= float(n)
      do i=1,n
        s = s - dcos(x(i))
      end do   
      do i=1,n
        temp(i) = s + float(i)*(1.d0-dcos(x(i))) - dsin(x(i))
      end do 

      f = 0.d0
      do i=1,n
        f = f + temp(i)**2
      end do   
      
* Gradient
      
      s=0.d0
      do i=1,n
        s = s + temp(i)
      end do
      
      do i=1,n
        g(i) = 2.d0*s*dsin(x(i)) + 
     +            2.d0*temp(i)*(float(i)*dsin(x(i))-dcos(x(i)))  
      end do      
      
      return
      end
**************************************************************






cF3                    Extended Rosenbrock function
*
*              Initial point: [-1.2, 1, ..........., -1.2, 1]      

      
      subroutine evalfg(n,x,f,g)
      integer i, n
      double precision f, c, x(n),g(n)
                           
      c=100.d0                           
                           
      f=0.d0
      do i=1,n/2
        f = f + c*(x(2*i)-x(2*i-1)**2)**2 + (1.d0-x(2*i-1))**2
      end do  

*-- Gradient
               
      j=1
      do i=1,n/2
        g(j)   = -4.d0*c*x(2*i-1)*(x(2*i)-x(2*i-1)**2) - 
     *            2.d0*(1.d0-x(2*i-1))
        g(j+1) =  2.d0*c*(x(2*i)-x(2*i-1)**2)
        j = j + 2
      end do
      
      return
      end

c******************************************************************







cF4                    Extended White & Holst function
*
*           Initial point: [-1.2, 1, -1.2, 1, ..........., -1.2, 1]      
      
      subroutine evalfg(n,x,f,g)
      integer i, n
      double precision f, c, x(n),g(n)
                           
      c=100.d0                           
                           
      f=0.d0
      do i=1,n/2
        f = f + c*(x(2*i)-x(2*i-1)**3)**2 + (1.d0-x(2*i-1))**2
      end do  

*-- Gradient
               
      j=1
      do i=1,n/2
        g(j)   = -6.d0*c*x(2*i-1)*x(2*i-1)*(x(2*i)-x(2*i-1)**3) - 
     *            2.d0*(1.d0-x(2*i-1))
        g(j+1) =  2.d0*c*(x(2*i)-x(2*i-1)**3)
        j = j + 2
      end do
      
      return
      end

c******************************************************************





*
cF5                      Extended Beale Function  
*
*                   Initial Point: [1, 0.8, ...., 1, 0.8]
*--------------------------------------------------------------
*
      subroutine evalfg(n,x,f,g)
      integer i, n
      double precision f, x(n),g(n)
      real*8 t1,t2,t3
*      
      f=0.d0
      n1=n/2    
*
      j=1      
      do i=1,n1 
        t1=1.5d0  -x(2*i-1)+x(2*i-1)*x(2*i)
        t2=2.25d0 -x(2*i-1)+x(2*i-1)*x(2*i)*x(2*i)
        t3=2.625d0-x(2*i-1)+x(2*i-1)*x(2*i)*x(2*i)*x(2*i)   
        
        f = f + t1*t1 + t2*t2 + t3*t3

*-- Gradient

        g(j)  =2.d0*t1*(-1.d0+x(2*i)) +
     *         2.d0*t2*(-1.d0+x(2*i)**2) +
     *         2.d0*t3*(-1.d0+x(2*i)**3)   
        g(j+1)=2.d0*t1*x(2*i-1) +
     *         2.d0*t2*2.d0*x(2*i-1)*x(2*i) +
     *         2.d0*t3*3.d0*x(2*i-1)*x(2*i)*x(2*i)   
        j=j+2        
      end do   
*   
      return
      end
C****************************************************************
 






cF6                   Extended Penalty Function 
*
*                   Intial Point: [1,2,3,.....,n].
*  

      subroutine evalfg(n,x,f,g)
      integer i, n
      double precision f, x(n),g(n)
      real*8 temp
      
      temp=0.d0
      do i=1,n
        temp = temp + x(i)**2
      end do
*      
      f = (temp - 0.25d0)**2
      
      do i=1,n-1
        f = f + (x(i)-1.d0)**2 
      end do

*-- Gradient       

      do i=1,n-1
        g(i) = 2.d0*(x(i)-1.d0) + 4.d0*x(i)*(temp-0.25d0)
      end do                                              
      
      g(n) = 4.d0*x(n)*(temp-0.25d0)
                
*  
      return
      end
c******************************************************************






cF7                       Perturbed Quadratic function
*           
*                   Initial Point:  [0.5, 0.5, ......, 0.5].
*     
      subroutine evalfg(n,x,f,g)
      double precision f, x(n),g(n)
      real*8 temp
      
      temp = 0.d0
      do i=1,n
        temp = temp + x(i)
      end do  
      
      f = temp*temp/100.d0
      
      do i=1,n
        f = f + float(i)*x(i)**2      
      end do
      
*-- Gradient       
            
      do i=1,n
        g(i) = float(i) * 2.d0 * x(i) + temp/50.d0
      end do        

      return
      end
c******************************************************************




*
cF8                        Raydan 1 Function
*
*                   Initial point: [1, 1, ..., 1]

      subroutine evalfg(n,x,f,g)
      integer n
      double precision f, x(n),g(n)
      
      f=0.d0
      do i=1,n
        f = f + float(i) * (dexp(x(i))-x(i)) / 10.d0
      end do  
      
*-- Gradient       

      do i=1,n
        g(i) = float(i) * (dexp(x(i)) - 1.d0) / 10.d0      
      end do  

      return
      end
c******************************************************************






cF9                           Raydan 2 Function
*
*                       Initial Point: [1, 1, .....,1]
*  
      subroutine evalfg(n,x,f,g)
      real*8 f, x(n), g(n)
      
      f=0.d0
      
      do i=1,n
        f = f + dexp(x(i)) - x(i)
      end do

*-- Gradient
      
      do i=1,n
        g(i) = dexp(x(i)) - 1.d0
      end do
      
      return
      end
c*****************************************************************  






cF10                             Diagonal1 Function
*
*                       Initial Point: [1/n, 1/n, ....., 1/n]
*  
      subroutine evalfg(n,x,f,g)
      real*8 f, x(n), g(n)
      
      f=0.d0
      
      do i=1,n
        f = f + dexp(x(i)) - x(i)*float(i)
      end do

*-- Gradient
      
      do i=1,n
        g(i) = dexp(x(i)) - float(i)
      end do
      
      return
      end
c*****************************************************************  







cF11                             Diagonal2 Function
*
*                       Initial Point: [1/1, 1/2, ....., 1/n]
*  
      subroutine evalfg(n,x,f,g)
      real*8 f, x(n), g(n)
      
      f=0.d0
      
      do i=1,n
        f = f + dexp(x(i)) - x(i)/float(i)
      end do

*-- Gradient
      
      do i=1,n
        g(i) = dexp(x(i)) - 1.d0/float(i)
      end do
      
      return
      end
c*****************************************************************  








cF12                         Diagonal3 Function
*
*                        Initial Point: [1,1,...,1] 


      subroutine evalfg(n,x,f,g)
      real*8 f, x(n), g(n)
      
      f=0.d0
      
      do i=1,n
        f = f + dexp(x(i)) - float(i)*dsin(x(i))
      end do

*-- Gradient
      
      do i=1,n
        g(i) = dexp(x(i)) - float(i)*dcos(x(i))
      end do
      
      return
      end
c*****************************************************************    





cF13                           Hager Function
*
*                        Initial Point: [1,1,...,1] 


      subroutine evalfg(n,x,f,g)
      real*8 f, x(n), g(n)
      
      f=0.d0
      
      do i=1,n
        f = f + dexp(x(i)) - x(i)*sqrt(float(i))
      end do

*-- Gradient
      
      do i=1,n
        g(i) = dexp(x(i)) - sqrt(float(i))
      end do
      
      return
      end
c*****************************************************************          





cF14                 Generalized Tridiagonal-1 Function
*
*                        Initial Point: [2,2,...,2] 


      subroutine evalfg(n,x,f,g)
      real*8 f, x(n), g(n)
      real*8 u(11000), v(11000)
      
      f=0.d0
      
      do i=1,n-1
        u(i) = x(i) + x(i+1) - 3.d0
        v(i) = x(i) - x(i+1) + 1.d0
      end do
      
      do i=1,n-1
        f = f + u(i)**2 + v(i)**4
      end do
      
*-- Gradient  
                     
      g(1) = 2.d0*u(1) + 4.d0*v(1)**3
      
      do i=2,n-1
        g(i) = 2.d0*u(i-1) - 4.d0*v(i-1)**3 + 2.d0*u(i) + 4.d0*v(i)**3
      end do
      
      g(n) = 2.d0*u(n-1) - 4.d0*v(n-1)**3                         
                       
      return
      end
c*****************************************************************    





cF15                   Extended Tridiagonal-1 Function
*
*                         Initial Point: [2,2,...,2] 


      subroutine evalfg(n,x,f,g)
      real*8 f, x(n), g(n)
      real*8 u(11000), v(11000)
      
      f=0.d0
      
      do i=1,n/2
        u(i) = x(2*i-1) + x(2*i) - 3.d0
        v(i) = x(2*i-1) - x(2*i) + 1.d0
      end do
      
      do i=1,n/2
        f = f + u(i)**2 + v(i)**4
      end do

*-- Gradient
                       
      j=1
      do i=1,n/2
        g(j)   = 2.d0*u(i) + 4.d0*v(i)**3
        g(j+1) = 2.d0*u(i) - 4.d0*v(i)**3
        j=j+2
      end do                        
                       
      return
      end
c*****************************************************************    







cF16                     Extended Three Exponential Terms
*                 
*                        Intial Point: [0.1,0.1,.....,0.1].
*

      subroutine evalfg(n,x,f,g)      
      double precision f, x(n),g(n), t1,t2,t3
*
      f=0.d0   
      
      j=1
      do i=1,n/2
        t1=x(j) + 3.d0*x(j+1) - 0.1d0
        t2=x(j) - 3.d0*x(j+1) - 0.1d0
        t3=-x(j) - 0.1d0 
        
        f = f + dexp(t1) + dexp(t2) + dexp(t3)    

*-- Gradient
        
        g(j)   = dexp(t1) + dexp(t2) - dexp(t3)
        g(j+1) = 3.d0*dexp(t1) - 3.d0*dexp(t2)        
        
        j=j+2
      end do  
*
      return
      end
c******************************************************************







cF17                       Generalized Tridiagonal-2  
*                      
*                      Initial point: [-1, .........., -1] 
 
      subroutine evalfg(n,x,f,g)
      double precision f, x(n),g(n)
      real*8 t(15000), v(15000)     
      
      f = 0.d0
      t(1) = 5.d0*x(1)-3.d0*x(1)**2-x(1)**3-3.d0*x(2)+1.d0
      
      do i=2,n-1
        t(i)=5.d0*x(i)-3.d0*x(i)**2-x(i)**3-x(i-1)-3.d0*x(i+1)+1.d0
      end do      
                
      t(n)=5.d0*x(n)-3.d0*x(n)**2-x(n)**3-x(n-1)+1.d0        
      
      do i=1,n   
        f = f + t(i)**2
        v(i) = 5.d0 -6.d0*x(i) -3.d0*x(i)**2
      end do    
      
*-- Gradient

      g(1) = 2.d0*t(1)*v(1) - 2.d0*t(2)
      
      do i=2,n-1
        g(i) = -6.d0*t(i-1) +2.d0*t(i)*v(i) -2.d0*t(i+1)
      end do
      
      g(n) = -6.d0*t(n-1) +2.d0*t(n)*v(n)  
      return
      end
      
C******************************************************************      







cF18                       Diagonal4 Function  
*                      
*                Initial point: [1, 1, .........., 1., 1] 
 
      subroutine evalfg(n,x,f,g)
      double precision f, x(n),g(n)
      real*8 c
      
      c=100.d0
      
      f = 0.d0
     
      do i=1,n/2
        f = f + (x(2*i-1)**2 + c*x(2*i)**2)/2.d0
      end do                  
      
*-- Gradient

      j=1
      do i=1,n/2
        g(j)   = x(2*i-1)
        g(j+1) = c*x(2*i)
        j=j+2
      end do  

      return
      end
      
C******************************************************************      







cF19                           Diagonal5 Function
*                      
*                    Initial point: [1.1, 1.1, .........., 1.1] 
 
      subroutine evalfg(n,x,f,g)
      double precision f, x(n),g(n)
      
      f = 0.d0
     
      do i=1,n
        f = f + dlog( dexp(x(i)) + dexp(-x(i)) )
      end do                  
      
*-- Gradient

      do i=1,n
        g(i) = (dexp(x(i)) - dexp(-x(i)))/(dexp(x(i)) + dexp(-x(i)))
      end do  

      return
      end
      
C******************************************************************      





cF20                       Extended Himmelblau Function
*          
*                        Initial Point: [1, 1, ....., 1]

      subroutine evalfg(n,x,f,g)
      real*8 f, x(n), g(n)
      real*8 u,v
      
      f=0.d0
      j=1
      
      do i=1,n/2
        u = x(2*i-1)**2 + x(2*i)    - 11.d0
        v = x(2*i-1)    + x(2*i)**2 - 7.d0 
        
        f = f + u*u + v*v

*-- Gradient
        
        g(j)   = 4.d0*u*x(2*i-1) + 2.d0*v
        g(j+1) = 2.d0*u          + 4.d0*v*x(2*i)
        j=j+2
      end do
      
      return
      end
c*****************************************************************  







cF21                    Generalized Rosenbrock function
*
*        Initial point: [-1.2, 1, -1.2, 1, ..........., -1.2, 1]      
 
 
      
      subroutine evalfg(n,x,f,g)
      integer i, n
      double precision f, c, x(n),g(n)
                           
      c=100.d0                           
                           
      f=0.d0
      do i=1,n-1
        f = f + c*(x(i+1)-x(i)*x(i))**2 + (1.d0-x(i))**2
      end do
        
*-- Gradient

      g(1) = -4.d0*c*x(1)*(x(2)-x(1)*x(1)) - 2.d0*(1.d0-x(1))
      
      do i=2,n-1
        g(i) = 2.d0*c*(x(i)-x(i-1)**2) -
     +         4.d0*c*x(i)*(x(i+1)-x(i)**2) - 2.d0*(1.d0-x(i))
      end do
      
      g(n) = 2.d0*c*(x(n)-x(n-1)**2)
      
      return
      end

c******************************************************************






cF22                   Generalized White & Holst function
* 
*          Initial point: [-1.2, 1, -1.2, 1, ..........., -1.2, 1]      
      
      subroutine evalfg(n,x,f,g)
      integer i, n
      double precision f, c, x(n),g(n)
                           
      c=100.d0 
      
      f=0.d0
      do i=1,n-1
        f = f + c*(x(i+1)-x(i)**3)**2 + (1.d0-x(i))**2
      end do 

*-- Gradient
      
      g(1) = -6.d0*c*x(1)*x(1)*(x(2)-x(1)**3) - 2.d0*(1.d0-x(1))
      
      do i=2,n-1
        g(i) = 2.d0*c*(x(i)-x(i-1)**3) -
     +         6.d0*c*x(i)*x(i)*(x(i+1)-x(i)**3) - 2.d0*(1.d0-x(i))
      end do
      
      g(n) = 2.d0*c*(x(n)-x(n-1)**3) 
      
      return
      end

c****************************************************************** 





cF23                     Generalized PSC1 Function
*
*                   Initial point: [3, 0.1, ..., 3, 0.1]

      subroutine evalfg(n,x,f,g)
      integer n
      double precision f, x(n),g(n)   

      f = 0.d0
      do i=1,n-1
        f = f + (x(i)**2 +x(i+1)**2 +x(i)*x(i+1))**2 
     *        + (dsin(x(i)))**2 + (dcos(x(i+1)))**2    
      end do
  
*-- Gradient     

      g(1)=   2.d0*(x(1)**2+x(2)**2+x(1)*x(2))*(2.d0*x(1)+x(2)) 
     *       +2.d0 * dsin(x(1)) * dcos(x(1))
      
      do i=2,n-1
      g(i) =  2.d0*(x(i-1)**2+x(i)**2+x(i-1)*x(i))*(2.d0*x(i)+x(i-1))
     +       +2.d0*(x(i)**2+x(i+1)**2+x(i)*x(i+1))*(2.d0*x(i)+x(i+1))
      end do

      g(n) =  2.d0*(x(n-1)**2+x(n)**2+x(n-1)*x(n))*(2.d0*x(n)+x(n-1))
     +       -2.d0*dcos(x(n)) * dsin(x(n)) 

      return
      end

c****************************************************************** 






cF24                       Extended PSC1 Function
*
*                   Initial point: [3, 0.1, ..., 3, 0.1]

      subroutine evalfg(n,x,f,g)
      double precision f, x(n),g(n)   

      f = 0.d0
      do i=1,n/2
        f = f + (x(2*i-1)**2 +x(2*i)**2 +x(2*i-1)*x(2*i))**2 
     *        + (dsin(x(2*i-1)))**2 + (dcos(x(2*i)))**2    
      end do
  
*-- Gradient    

      j=1
      do i=1,n/2
      g(j)   = 2.d0*(x(2*i-1)**2+x(2*i)**2+x(2*i-1)*x(2*i)) *
     +              (2.d0*x(2*i-1)+x(2*i)) +
     +              2.d0*(dsin(x(2*i-1)))*(dcos(x(2*i-1)))
     
      g(j+1) = 2.d0*(x(2*i-1)**2+x(2*i)**2+x(2*i-1)*x(2*i)) *
     +              (2.d0*x(2*i)+x(2*i-1)) -
     +              2.d0*(dcos(x(2*i)))*(dsin(x(2*i)))
      j=j+2
      end do

      return
      end

c****************************************************************** 





cF25                            Extended Powell 
*
*                      Initial Point: [3, -1, 0, 1, ......].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)  
      real*8 t1,t2,t3,t4
*      
      f=0.d0
      
      j=1    
      do i=1,n/4  
        t1= x(4*i-3) + 10.d0*x(4*i-2) 
        t2= x(4*i-1) - x(4*i)
        t3= x(4*i-2) - 2.d0*x(4*i-1)
        t4= x(4*i-3) - x(4*i)     
       
        f = f + t1*t1 + 5.d0*t2*t2 + t3**4 + 10.d0*t4**4      

*-- Gradient
        
        g(j)  =   2.d0*t1 + 40.d0*t4**3
        g(j+1)=  20.d0*t1 +  4.d0*t3**3
        g(j+2)=  10.d0*t2 -  8.d0*t3**3
        g(j+3)= -10.d0*t2 - 40.d0*t4**3
        
        j=j+4        
      end do               
      
      return
      end                                                             
*
****************************************************************




cF26                         Full Hessian FH1 Function 
*
*                      Initial Point: [0.01, 0.01, ..., 0.01].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)  
      real*8 t(11000), v(11000)
      
      f = (x(1)-3.d0)**2
      
      t(1) = x(1)+x(2)
      do i=2,n-1
        t(i)= t(i-1) + x(i+1)
      end do         
      
      do i=1,n-1
        v(i) = x(1) - 3.d0 - 2.d0*t(i)*t(i)
      end do
      
      do i=1,n-1
        f = f + v(i)*v(i)
      end do
          
*-- Gradient
           
      g(1) = 2.d0*(x(1)-3.d0)
      do i=1,n-1
        g(1) = g(1) + 2.d0*v(i)*(1.d0-4.d0*t(i))
      end do  
*      
      do i=2,n               
        g(i) = 0.d0
        do j=i-1,n-1            
          g(i) = g(i) - 8.d0*v(j)*t(j)
        end do
      end do
      
      return
      end    
      
****************************************************************




cF27                        Full Hessian FH2 Function 
*
*                      Initial Point: [0.01, 0.01, ..., 0.01].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)  
      real*8 t(11000)

      t(1) = x(1)+x(2)-1.d0
      do i=2,n-1
        t(i) = t(i-1) + x(i+1)
      end do
      
      f = (x(1)-5.d0)**2
      
      do i=1,n-1
        f = f + t(i)**2
      end do

*-- Gradient

      g(1) = 2.d0*(x(1)-5.d0)
      do i=1,n-1
        g(1) = g(1) + 2.d0*t(i)
      end do
      
      do i=2,n
        g(i) = 0.d0
        do j=i-1,n-1
          g(i) = g(i) + 2.d0*t(j)                  
        end do
      end do
      
      return
      end
********************************************************************          
      



cF28                  Extended Block Diagonal BD1 Function 
*
*                      Initial Point: [0.1, 0.1, ..., 0.1].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)  
      real*8 t1,t2
      
      f = 0.d0
      
      j=1
      do i=1,n/2
        t1 = x(2*i-1)**2 + x(2*i)**2 - 2.d0
        t2 = dexp(x(2*i-1)) - x(2*i)
        
        f = f + t1*t1 + t2*t2

*-- Gradient
        
        g(j)   = 4.d0*t1*x(2*i-1) + 2.d0*t2*dexp(x(2*i-1)-1.d0)
        g(j+1) = 4.d0*t1*x(2*i) - 2.d0*t2
        j=j+2
      end do
      
      return
      end    
      
****************************************************************





cF29                         Extended Maratos Function 
*
*                      Initial Point: [1.1, 0.1, ...,1.1, 0.1].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)  
      real*8 t1, c
      
      c = 100.d0
      f = 0.d0
      
      j=1
      do i=1,n/2
        t1 = x(2*i-1)**2 + x(2*i)**2 - 1.d0
        
        f = f + (x(2*i-1) + c*t1*t1)

*-- Gradient
        
        g(j)   = 1.d0 + 4.d0 * c * t1 * x(2*i-1)
        g(j+1) =        4.d0 * c * t1 * x(2*i)
        j=j+2
      end do
      
      return
      end    
      
****************************************************************




cF30                             Extended Cliff                  
*
*                     Initial Point:  [0, -1, ......, 0, -1].
*                     

      subroutine evalfg(n,x,f,g)
      double precision f, x(n),g(n)
      real*8 temp
      
      f=0.d0
        
      j=1  
      do i=1,n/2
        temp = (x(2*i-1)-3.d0)/100.d0
        
        f = f+temp*temp-(x(2*i-1)-x(2*i))+dexp(20.d0*(x(2*i-1)-x(2*i)))

*-- Gradient
        
        g(j)   = temp/50.d0 - 1.d0 + 20.d0*dexp(20.d0*(x(2*i-1)-x(2*i)))
        g(j+1) = 1.d0 - 20.d0*dexp(20.d0*(x(2*i-1)-x(2*i)))
        j=j+2
      end do
      
      return
      end
      
******************************************************************        






cF31                   Quadratic Diagonal Perturbed Function
*
*                     Initial Point:  [0.5, 0.5, ......, 0.5].
*     
      subroutine evalfg(n,x,f,g)
      double precision f, x(n),g(n)
      real*8 temp
      
      temp = 0.d0
      do i=1,n
        temp = temp + x(i)
      end do  
      
      f = temp*temp
      
      do i=1,n
        f = f + (float(i)/100.d0) * x(i)**2      
      end do
      
*-- Gradient        
            
      do i=1,n
        g(i) = float(i) * x(i) / 50.d0 + 2.d0*temp
      end do        

      return
      end
c******************************************************************




cF32                         Dai & Yang  Function
*
*                     Initial Point:  [0., 0., ......, 0.].
*     
      subroutine evalfg(n,x,f,g)
      double precision f, x(n),g(n)
      real*8 b(11000)
      
      f=x(1)*(2.d0*x(1)-x(2))  
      
      do i=2,n-1
        f = f + x(i)*(-x(i-1)+2.d0*x(i)-x(i+1))
      end do    

      f = f + x(n)*(-x(n-1)+2.d0*x(n))

      f = f/2.d0
      
      do i=1,n
        b(i) = 0.d0
        do j=1,n
          b(i) = b(i) + dsin(j*i*3.14159d0/(n+1))         
        end do           
      end do     
      
      do i=1,n
        f = f - b(i)*x(i)
      end do     

*-- Gradient

      g(1) = 4.d0*x(1) - 2.d0*x(2) - b(1)   
      
      do i=2,n-1
        g(i) = -2.d0*x(i-1) + 4.d0*x(i) - 2.d0*x(i+1) - b(i)
      end do  
      
      g(n) = -2.d0*x(n-1) + 4.d0*x(n) - b(n)

      return
      end
c******************************************************************



cF33                           Extended Wood Function
*
*                        Initial Point: [-3,-1,-3,-1,......]
*
      subroutine evalfg(n,x,f,g)
      real*8 f, x(n),g(n)
      
      f=0.d0
      
      j=1
      do i=1,n/4
        f = f + 100.d0*(x(4*i-3)**2-x(4*i-2))**2 
     *        +        (x(4*i-3)-1.d0)**2  
     *        +  90.d0*(x(4*i-1)**2-x(4*i))**2            
     *        +        (1.d0-x(4*i-1))**2
     *        +  10.1d0*(x(4*i-2)-1.d0)**2
     *        +  10.1d0*(x(4*i)  -1.d0)**2
     *        +  19.8d0*(x(4*i-2)-1.d0)*(x(4*i)-1.d0)

*-- Gradient
     
        g(j)   = 400.d0*(x(4*i-3)**2-x(4*i-2))*x(4*i-3)
     *             + 2.d0*(x(4*i-3)-1.d0)
        g(j+1) =-200.d0*(x(4*i-3)**2-x(4*i-2))
     *             + 20.2d0*(x(4*i-2)-1.d0)   
     *             + 19.8d0*(x(4*i)-1.d0)
        g(j+2) = 360.d0*(x(4*i-1)**2-x(4*i))*x(4*i-1)
     *             - 2.d0*(1.d0-x(4*i-1))   
        g(j+3) =-180.d0*(x(4*i-1)**2-x(4*i))
     *             + 20.2d0*(x(4*i)  -1.d0)
     *             + 19.8d0*(x(4*i-2)-1.d0)   
        j=j+4
      end do

      return
      end
*********************************************************************



cF34                        Extended Hiebert Function
*
*                           Initial Point: [0,0,...0].

      subroutine evalfg(n,x,f,g)
      real*8 f, x(n),g(n)
      real*8 c1,c2
      
      c1=10.d0
      c2=50000.d0
      
      f = 0.d0
      
      j=1
      do i=1,n/2
        f = f + (x(2*i-1)-c1)**2 + (x(2*i-1)*x(2*i)-c2)**2

*-- Gradient

        g(j)   =   2.d0*(x(2*i-1)-c1) 
     *           + 2.d0*(x(2*i-1)*x(2*i)-c2)*x(2*i)       
        g(j+1) =   2.d0*(x(2*i-1)*x(2*i)-c2)*x(2*i-1)
        j=j+2
      end do
      
      return
      end
***********************************************************************        


cF35                         Quadratic QF1 Function
*
*                           Initial Point: [1,1,...1].

      subroutine evalfg(n,x,f,g)
      real*8 f, x(n),g(n)
      
      f = 0.d0
      
      do i=1,n
        f = f + float(i)*x(i)*x(i)
        g(i)   =   float(i) * x(i)
      end do
      
      f = f/2.d0
      f = f - x(n)

      g(n) = g(n) - 1.d0
            
      return
      end
***********************************************************************        



cF36                Extended Quadratic Penalty QP1 Function           
*
*                      Initial Point:  [1, 1, ......,1].
*                     

      subroutine evalfg(n,x,f,g)
      double precision f, x(n),g(n)
      real*8 t
      
      t=0.d0
      do i=1,n
        t = t + x(i)*x(i)
      end do
      t = t - 0.5d0  
                   
      f = 0.d0                   
      do i=1,n-1
        f = f + (x(i)*x(i) - 2.d0)**2
        g(i) = 4.d0*(x(i)*x(i)-2.d0)*x(i) + 4.d0*t*x(i)
      end do  
      
      f = f + t*t
      g(n) = 4.d0*t*x(n)
      
      return
      end
      
******************************************************************        
              


cF37               Extended Quadratic Penalty QP2 Function           
*
*                     Initial Point:  [1, 1, ......,1].
*                     

      subroutine evalfg(n,x,f,g)
      double precision f, x(n),g(n)
      real*8 t
      
      t=0.d0
      do i=1,n
        t = t + x(i)*x(i)
      end do
      t = t - 100.d0  
                   
      f = 0.d0                   
      do i=1,n-1
        f = f + (x(i)*x(i) - dsin(x(i)))**2
        g(i) = 2.d0*(x(i)*x(i)-dsin(x(i)))*(2.d0*x(i)-dcos(x(i))) 
     *       + 4.d0*t*x(i)
      end do  
      
      f = f + t*t
      g(n) = 4.d0*t*x(n)
      
      return
      end
      
******************************************************************        



cF38                      Quadratic QF2 Function
*
*                  Initial Point:  [0.5, 0.5, ......,0.5].
*                     

      subroutine evalfg(n,x,f,g)
      double precision f, x(n),g(n) 
      
      f=0.d0
      do i=1,n 
        f = f + float(i)*(x(i)**2 - 1.d0)**2
      end do
      
      f = f/2.d0
      f = f - x(n)

*-- Gradient

      do i=1,n
        g(i) = float(i)*2.d0*x(i)*(x(i)**2 - 1.d0)
      end do
      g(n) = g(n) - 1.d0
      
      return
      end
********************************************************************            
        


cF39                       Extended EP1 Function 
*
*                      Initial Point: [0.,0.,...,0].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)  
      real*8 t1,t2,t3
      
      f=0.d0
      
      j=1                                     
      do i=1,n/2                                     
        t1=dexp(x(2*i-1)-x(2*i)) - 5.d0        
        t2=x(2*i-1)-x(2*i)
        t3=x(2*i-1)-x(2*i)-11.d0
        
        f = f + t1*t1 + (t2*t2)*(t3*t3)

*-- Gradient
      
        g(j) =   2.d0*t1*dexp(x(2*i-1)-x(2*i)) 
     *         + 2.d0*t2*t3*t3 
     *         + 2.d0*t2*t2*t3         
        g(j+1) = - g(j)
        j=j+2
      end do  
      
      return
      end                                                             
*
****************************************************************



cF40                  Extended Tridiagonal-2 Function 
*
*                      Initial Point: [1.,1.,...,1.].
*-------------------------------------------------------------------
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)  
      real*8 c
      
      c=0.1d0
      f=0.d0
      
      do i=1,n-1                                    
        f = f + (x(i)*x(i+1)-1.d0)**2 + c*(x(i)+1.d0)*(x(i+1)+1.d0)
      end do

*-- Gradient
      
      g(1) = 2.d0*(x(1)*x(2)-1.d0)*x(2) + c*(x(2)+1.d0)
      
      do i=2,n-1
        g(i) = 2.d0*(x(i-1)*x(i)-1.d0)*x(i-1) + c*(x(i-1)+1.d0) +
     *         2.d0*(x(i)*x(i+1)-1.d0)*x(i+1) + c*(x(i+1)+1.d0)
      end do 
                                               
      g(n) = 2.d0*(x(n-1)*x(n)-1.d0)*x(n-1) + c*(x(n-1)+1.d0)

      return
      end                                                             
*
****************************************************************


cF41                              FLETCBV3 
*
*                Initial Point: [1/(n+1),2/(n+1).,...,n/(n+1)].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)  
      real*8 kappa, objscale,p,h, c1,c2
      
      kappa = 1.d0
      objscale = 100000000.d0
      h = 1.d0/(float(n)+1.d0)
      p = 1.d0/objscale                                 

      c1 = p*(h*h+2.d0)/(h*h)
      c2 = kappa*p/(h*h)                
                       
      f=0.5d0*p*(x(1)**2 + x(n)**2)
      
      do i=1,n-1
        f = f + 0.5d0*p*(x(i)-x(i+1))**2
      end do
      
      do i=1,n
        f = f - c1*x(i) - c2*dcos(x(i))
      end do
      
*-- Gradient

      g(1) = 2.d0*p*x(1) - p*x(2) - c1 + c2*dsin(x(1))
      
      do i=2,n-1
        g(i) = -p*(x(i-1)-x(i)) + p*(x(i)-x(i+1)) - c1 + c2*dsin(x(i))
      end do
      
      g(n) = 2.d0*p*x(n) - p*x(n-1) - c1 + c2*dsin(x(n))            
                                       
      return
      end                                                             
*
****************************************************************


cF42                              FLETCHCR 
*
*                      Initial Point: [0.,0.,...,0.].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n), c  

      f=0.d0
      c=100.d0       
      
      do i=1,n-1
        f = f + c*(x(i+1)-x(i)+1.d0-x(i)**2)**2
      end do
      
*-- Gradient      
      
      g(1) = 2.d0*c*(x(2)-x(1)+1.d0-x(1)**2)*(-1.d0-2.d0*x(1))
      
      do i=2,n-1
        g(i) = 2.d0*c*(x(i)-x(i-1)+1.d0-x(i-1)**2) +  
     *         2.d0*c*(x(i+1)-x(i)+1.d0-x(i)**2)*(-1.d0-2.d0*x(i))
      end do     
      
      g(n) = 2.d0*c*(x(n)-x(n-1)+1.d0-x(n-1)**2)
                                       
      return
      end                                                             
*
****************************************************************



cF43                              BDQRTIC (CUTE)
*
*                     Initial point x0=[1.,1.,...,1.].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)
      real*8 t(11000), tsum
        
      n4=n-4
      f=0.d0
        
      do i=1,n4
        t(i) = x(i)**2 + 2.d0*x(i+1)**2 + 3.d0*x(i+2)**2 
     *                 + 4.d0*x(i+3)**2 + 5.d0*x(n)**2
      end do           
        
      do i=1,n4
        f = f + (-4.d0*x(i)+3.d0)**2 + t(i)**2
      end do                                  

*-- Gradient

      g(1) = -8.d0*(-4.d0*x(1)+3.d0) + 
     *        (4.d0*t(1))*x(1)        
      g(2) = -8.d0*(-4.d0*x(2)+3.d0) + 
     *        (8.d0*t(1)+  4.d0*t(2))*x(2)
      g(3) = -8.d0*(-4.d0*x(3)+3.d0) + 
     *        (12.d0*t(1)+ 8.d0*t(2)+ 4.d0*t(3))*x(3)
      g(4) = -8.d0*(-4.d0*x(4)+3.d0) + 
     *        (16.d0*t(1)+12.d0*t(2) +8.d0*t(3)+4.d0*t(4))*x(4)
        
      do i=5,n4
        g(i) = -8.d0*(-4.d0*x(i)+3.d0) + 
     *         (16.d0*t(i-3)+12.d0*t(i-2)+8.d0*t(i-1)+4.d0*t(i))*x(i)                                                        
      end do
        
      g(n4+1) = (16.d0*t(n4-2)+12.d0*t(n4-1)+8.d0*t(n4))*x(n4+1)  
      g(n4+2) = (16.d0*t(n4-1)+12.d0*t(n4))*x(n4+2)
      g(n4+3) = (16.d0*t(n4))*x(n4+3)
          
      tsum=0.d0
      do i=1,n4
        tsum = tsum + t(i)
      end do
      g(n) = 20.d0*tsum*x(n)
             
      return
      end
************************************************************       



cF44                                    VARDIM                               
*
*                     Initial point x0=[1-1/n,1-2/n,...,1-n/n].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)
      real*8 t
                  
      f=0.d0
      do i=1,n
        f = f + (x(i)-1.d0)**2
      end do
      
      t=0.d0
      do i=1,n
        t = t + float(i)*x(i)
      end do
      
      t = t - float(n)*float(n+1)/2.d0
      f = f + t**2 + t**4

*-- Gradient
                
      do i=1,n
        g(i) = 2.d0*(x(i)-1.d0) + 2.d0*float(i)*t + 4.d0*float(i)*(t**3)      
      end do  

      return
      end

************************************************************          



cF45                            TRIDIA                               
*
*                     Initial point x0=[1,1,...,1].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)
      real*8 alpha, beta, gamma, delta
                
      alpha=2.d0
      beta=1.d0
      gamma=1.d0
      delta=1.d0
        
      f=gamma*(delta*x(1)-1.d0)**2
      
      do i=2,n
        f = f + float(i)*(alpha*x(i)-beta*x(i-1))**2
      end do
      
*-- Gradient

      g(1) = 2.d0*gamma*(delta*x(1)-1.d0)*delta - 
     *       4.d0*(alpha*x(2)-beta*x(1))*beta
     
      do i=2,n-1
        g(i) = 2.d0*float(i)*(alpha*x(i)-beta*x(i-1))*alpha -
     *         2.d0*float(i+1)*(alpha*x(i+1)-beta*x(i))*beta
      end do         

      g(n) = 2.d0*float(n)*(alpha*x(n)-beta*x(n-1))*alpha

      return
      end
************************************************************          




cF46                        ARGLINB  (m=20)                               
*
*                     Initial point x0=[1,1,...,1].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)
      real*8 sum

      m=20
              
      f=0.d0  
      
      sum=0.d0
      do i=1,n      
        sum = sum + float(i)*x(i)
      end do  
      
      do j=1,m
        f = f + (float(j)*sum - 1.d0)**2        
      end do
      
*-- Gradient

      do i=1,n
        g(i) = 0.d0
        do j=1,m
          g(i) = g(i) + 2.d0*float(i) * float(j)*(float(j)*sum - 1.d0)
        end do
      end do              
      
      return
      end
************************************************************          





cF47                          ARWHEAD                               
*
*                     Initial point x0=[1,1,...,1].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)

      f=0.d0
      do i=1,n-1
        f = f + (-4.d0*x(i)+3.d0) + (x(i)**2+x(n)**2)**2
      end do

*-- Gradient
      
      do i=1,n-1
        g(i) = -4.d0 + 4.d0*x(i)*(x(i)**2+x(n)**2)
      end do
      
      g(n) = 0.d0
      do i=1,n-1
        g(n) = g(n) + 4.d0*x(n)*(x(i)**2+x(n)**2)
      end do                    
      
      return
      end
************************************************************          


                                                                       


cF48                                                         
*                             NONDIA (Shanno-78)
*                     Initial point x0=[-1,-1,...,-1].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)
      real*8 c

      c=100.d0
      
      f=(x(1)-1.d0)**2 + c*(x(1)-x(1)**2)**2
      
      do i=2,n
        f = f + c*(x(1)-x(i)**2)**2
      end do
      
*-- Gradient   

      g(1)=2.d0*(x(1)-1.d0) + 2.d0*c*(x(1)-x(1)**2)*(1.d0-2.d0*x(1))        
      do i=2,n
        g(1) = g(1) + 2.d0*c*(x(1)-x(i)**2)
      end do  
      
      do i=2,n
        g(i) = -4.d0*c*x(i)*(x(1)-x(i)**2)
      end do        
              
      return
      end
************************************************************          
                                                                       


cF49                          NONDQUAR                               
*                             
*                  Initial point x0=[1,-1,1,-1,...,].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)

      f = (x(1)-x(2))**2 + (x(n-1)+x(n))**2      
      
      do i=1,n-2
        f = f + (x(i)+x(i+1)+x(n))**4
      end do
      
*-- Gradient   

      g(1) = 2.d0*(x(1)-x(2))+4.d0*(x(1)+x(2)+x(n))**3
      g(2) =-2.d0*(x(1)-x(2))+4.d0*(x(1)+x(2)+x(n))**3 +
     *                        4.d0*(x(2)+x(3)+x(n))**3
      
      do i=3,n-2
        g(i) = 4.d0*(x(i-1)+x(i)+x(n))**3 +
     *         4.d0*(x(i)+x(i+1)+x(n))**3
      end do          
      
      g(n-1) = 4.d0*(x(n-2)+x(n-1)+x(n))**3 +
     *         2.d0*(x(n-1)+x(n))
      
      g(n) = 2.d0*(x(n-1)+x(n))
      do i=1,n-2
        g(n) = g(n) + 4.d0*(x(i)+x(i+1)+x(n))**3
      end do  
              
      return
      end
************************************************************   

 
 
 
 
cF50                             QUARTC                              
*                             
*                     Initial point x0=[2,2,2...,2].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)

      f=0.d0
      do i=1,n
        f = f + (x(i)-1.d0)**4
      end do
      
*-- Gradient   

      do i=1,n
        g(i) = 4.d0*(x(i)-1.d0)**3
      end do          
              
      return
      end
************************************************************          
                                                                      
 
cF51                          DQDRTIC                              
*                             
*                     Initial point x0=[3,3,3...,3].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)
      real*8 c,d
      
      c=100.d0
      d=100.d0
      
      f=0.d0
      do i=1,n-2
        f = f + (x(i)**2 + c*x(i+1)**2 + d*x(i+2)**2)
      end do
      
*-- Gradient   

      g(1) = 2.d0*x(1)
      g(2) = 2.d0*c*x(2) + 2.d0*x(2)
      
      do i=3,n-2
        g(i) = 2.d0*(1.d0+d+c)*x(i)
      end do
      
      g(n-1) = 2.d0*(c+d)*x(n-1)          
      g(n) = 2.d0*d*x(n)
      
      return
      end
************************************************************           



cF52                             EG2                              
*                             
*                     Initial point x0=[1,1,1...,1].
*
*
      subroutine evalfg(n,x,f,g)
      real*8 x(n), f, g(n)

      f=0.5d0*dsin(x(n)*x(n))
      do i=1,n-1
        f = f + dsin(x(1)+x(i)*x(i)-1.d0)
      end do
      
*-- Gradient   

      g(1)=(1.d0+2.d0*x(1))*dcos(x(1)+x(1)*x(1)-1.d0)
      do i=2,n-1
        g(1) = g(1) + dcos(x(1)+x(i)*x(i)-1.d0)
      end do               
      
      do i=2,n-1
        g(i) = 2.d0*x(i)*dcos(x(1)+x(i)*x(i)-1.d0)
      end do
      
      g(n) = x(n)*dcos(x(n)*x(n))

      return
      end
************************************************************          
                                                                     


cF53                             CURLY20                              
*                             
*           Initial point x0=[0.0001/(n+1), ..., 0.0001/(n+1)].
*
   
        subroutine evalfg(n,x,f,g)        
        real*8 x(n), f, g(n)
        real*8 q(11000)
                  
        k=20                  
        f=0.d0
        
        do i=1,n-k
          q(i) = 0.d0
          do j=i,i+k
            q(i) = q(i) + x(j)
          end do
        end do

        do i=n-k+1, n
          q(i) = 0.d0
          do j=i,n
            q(i) = q(i) + x(j)
          end do
        end do

        do i=1,n
          f = f + (q(i)**4 - 20.d0*q(i)*q(i) - 0.1d0*q(i))
        end do 
        
*-- Gradient     

        g(1) = 4.d0*q(1)**3 - 40.d0*q(1) - 0.1d0                                  
        do i=2,k+1
          g(i) = 0.d0
          do j=1,i
            g(i) = g(i) + (4.d0*q(j)**3-40.d0*q(j)-0.1d0)
          end do
        end do

        do i=k+2,n
          g(i) = 0.d0
          do j=i-k, i
            g(i) = g(i) + (4.d0*q(j)**3-40.d0*q(j)-0.1d0)
          end do
        end do
        
        return
        end
**********************************************************      




cF54                             DIXMAANA                              
*                             
*                    Initial point x0=[2.,2.,2...,2.].
*
        subroutine evalfg(n,x,f,g)
        real*8 x(n), f, g(n)
        real*8 alpha, beta, gamma, delta                       
        integer k1, k2, k3, k4
    
        alpha = 1.d0
        beta  = 0.d0
        gamma = 0.125d0
        delta = 0.125d0
                      
        k1 = 0
        k2 = 0
        k3 = 0
        k4 = 0
           
        m = n/3
*--       
        f = 1.d0
        do i=1,n
          f = f + alpha * x(i)*x(i)* ((float(i)/float(n))**k1)
        end do
        
        do i=1,n-1
          f = f + beta*x(i)*x(i)*((x(i+1)+x(i+1)*x(i+1))**2) *
     *            ((float(i)/float(n))**k2)
        end do
        
        do i=1,2*m
          f = f + gamma * x(i)*x(i) * (x(i+m)**4) *
     *            ((float(i)/float(n))**k3)
        end do
        
        do i=1,m
          f = f + delta * x(i) * x(i+2*m) *
     *            ((float(i)/float(n))**k4)
        end do

*-- Gradient     

      do i=1,n
        g(i) =0.d0
      end do
        
      do i=1,n
        g(i) = g(i) + 2.d0*alpha*x(i)*((float(i)/float(n))**k1)  
      end do
      
      do i=1,n-1
        g(i) = g(i) + 2.d0*beta*x(i)*((x(i+1)+x(i+1)**2)**2)*
     *                ((float(i)/float(n))**k2)  
        g(i+1) = g(i+1) + beta*(x(i)**2)*2.d0*(x(i+1)+x(i+1)**2)*
     *                (1.d0+2.d0*x(i+1))*((float(i)/float(n))**k2)   
      end do
      
      do i=1,2*m
        g(i) = g(i) + 2.d0*gamma*x(i)*(x(i+m)**4)* 
     *                ((float(i)/float(n))**k3)      
        g(i+m) = g(i+m) + gamma*(x(i)**2)*4.d0*(x(i+m)**3)*
     *                ((float(i)/float(n))**k3)   
      end do
      
      do i=1,m
        g(i) = g(i) + delta*x(i+2*m)*((float(i)/float(n))**k4)
        g(i+2*m) = g(i+2*m) + delta*x(i)*((float(i)/float(n))**k4)
      end do  
        

     
        return
        end
*************************************************************        
                                        



cF55                             DIXMAANB                              
*                             
*                    Initial point x0=[2.,2.,2...,2.].
*
        subroutine evalfg(n,x,f,g)
        real*8 x(n), f, g(n)
        real*8 alpha, beta, gamma, delta                       
        integer k1, k2, k3, k4
    
        alpha = 1.d0
        beta  = 0.0625d0
        gamma = 0.0625d0
        delta = 0.0625d0
                      
        k1 = 0
        k2 = 0
        k3 = 0
        k4 = 0
           
        m = n/3
*--       
        f = 1.d0
        do i=1,n
          f = f + alpha * x(i)*x(i)* ((float(i)/float(n))**k1)
        end do
        
        do i=1,n-1
          f = f + beta*x(i)*x(i)*((x(i+1)+x(i+1)*x(i+1))**2) *
     *            ((float(i)/float(n))**k2)
        end do
        
        do i=1,2*m
          f = f + gamma * x(i)*x(i) * (x(i+m)**4) *
     *            ((float(i)/float(n))**k3)
        end do
        
        do i=1,m
          f = f + delta * x(i) * x(i+2*m) *
     *            ((float(i)/float(n))**k4)
        end do

*-- Gradient     

      do i=1,n
        g(i) =0.d0
      end do
        
      do i=1,n
        g(i) = g(i) + 2.d0*alpha*x(i)*((float(i)/float(n))**k1)  
      end do
      
      do i=1,n-1
        g(i) = g(i) + 2.d0*beta*x(i)*((x(i+1)+x(i+1)**2)**2)*
     *                ((float(i)/float(n))**k2)  
        g(i+1) = g(i+1) + beta*(x(i)**2)*2.d0*(x(i+1)+x(i+1)**2)*
     *                (1.d0+2.d0*x(i+1))*((float(i)/float(n))**k2)   
      end do
      
      do i=1,2*m
        g(i) = g(i) + 2.d0*gamma*x(i)*(x(i+m)**4)* 
     *                ((float(i)/float(n))**k3)      
        g(i+m) = g(i+m) + gamma*(x(i)**2)*4.d0*(x(i+m)**3)*
     *                ((float(i)/float(n))**k3)   
      end do
      
      do i=1,m
        g(i) = g(i) + delta*x(i+2*m)*((float(i)/float(n))**k4)
        g(i+2*m) = g(i+2*m) + delta*x(i)*((float(i)/float(n))**k4)
      end do  
        
     
        return
        end
*************************************************************        
                                        



cF56                             DIXMAANC                              
*                             
*                    Initial point x0=[2.,2.,2...,2.].
*
        subroutine evalfg(n,x,f,g)
        real*8 x(n), f, g(n)
        real*8 alpha, beta, gamma, delta                       
        integer k1, k2, k3, k4
    
        alpha = 1.d0
        beta  = 0.125d0
        gamma = 0.125d0
        delta = 0.125d0
                      
        k1 = 0
        k2 = 0
        k3 = 0
        k4 = 0
           
        m = n/3
*--       
        f = 1.d0
        do i=1,n
          f = f + alpha * x(i)*x(i)* ((float(i)/float(n))**k1)
        end do
        
        do i=1,n-1
          f = f + beta*x(i)*x(i)*((x(i+1)+x(i+1)*x(i+1))**2) *
     *            ((float(i)/float(n))**k2)
        end do
        
        do i=1,2*m
          f = f + gamma * x(i)*x(i) * (x(i+m)**4) *
     *            ((float(i)/float(n))**k3)
        end do
        
        do i=1,m
          f = f + delta * x(i) * x(i+2*m) *
     *            ((float(i)/float(n))**k4)
        end do

*-- Gradient     

      do i=1,n
        g(i) =0.d0
      end do
        
      do i=1,n
        g(i) = g(i) + 2.d0*alpha*x(i)*((float(i)/float(n))**k1)  
      end do
      
      do i=1,n-1
        g(i) = g(i) + 2.d0*beta*x(i)*((x(i+1)+x(i+1)**2)**2)*
     *                ((float(i)/float(n))**k2)  
        g(i+1) = g(i+1) + beta*(x(i)**2)*2.d0*(x(i+1)+x(i+1)**2)*
     *                (1.d0+2.d0*x(i+1))*((float(i)/float(n))**k2)   
      end do
      
      do i=1,2*m
        g(i) = g(i) + 2.d0*gamma*x(i)*(x(i+m)**4)* 
     *                ((float(i)/float(n))**k3)      
        g(i+m) = g(i+m) + gamma*(x(i)**2)*4.d0*(x(i+m)**3)*
     *                ((float(i)/float(n))**k3)   
      end do
      
      do i=1,m
        g(i) = g(i) + delta*x(i+2*m)*((float(i)/float(n))**k4)
        g(i+2*m) = g(i+2*m) + delta*x(i)*((float(i)/float(n))**k4)
      end do  
        
     
        return
        end
*************************************************************        




cF57                             DIXMAANE                              
*                             
*                    Initial point x0=[2.,2.,2...,2.].
*
        subroutine evalfg(n,x,f,g)
        real*8 x(n), f, g(n)
        real*8 alpha, beta, gamma, delta                       
        integer k1, k2, k3, k4
    
        alpha = 1.d0
        beta  = 0.d0
        gamma = 0.125d0
        delta = 0.125d0
                      
        k1 = 1
        k2 = 0
        k3 = 0
        k4 = 1
           
        m = n/3
*--       
        f = 1.d0
        do i=1,n
          f = f + alpha * x(i)*x(i)* ((float(i)/float(n))**k1)
        end do
        
        do i=1,n-1
          f = f + beta*x(i)*x(i)*((x(i+1)+x(i+1)*x(i+1))**2) *
     *            ((float(i)/float(n))**k2)
        end do
        
        do i=1,2*m
          f = f + gamma * x(i)*x(i) * (x(i+m)**4) *
     *            ((float(i)/float(n))**k3)
        end do
        
        do i=1,m
          f = f + delta * x(i) * x(i+2*m) *
     *            ((float(i)/float(n))**k4)
        end do

*-- Gradient

      do i=1,n
        g(i) =0.d0
      end do
        
      do i=1,n
        g(i) = g(i) + 2.d0*alpha*x(i)*((float(i)/float(n))**k1)  
      end do
      
      do i=1,n-1
        g(i) = g(i) + 2.d0*beta*x(i)*((x(i+1)+x(i+1)**2)**2)*
     *                ((float(i)/float(n))**k2)  
        g(i+1) = g(i+1) + beta*(x(i)**2)*2.d0*(x(i+1)+x(i+1)**2)*
     *                (1.d0+2.d0*x(i+1))*((float(i)/float(n))**k2)   
      end do
      
      do i=1,2*m
        g(i) = g(i) + 2.d0*gamma*x(i)*(x(i+m)**4)* 
     *                ((float(i)/float(n))**k3)      
        g(i+m) = g(i+m) + gamma*(x(i)**2)*4.d0*(x(i+m)**3)*
     *                ((float(i)/float(n))**k3)   
      end do
      
      do i=1,m
        g(i) = g(i) + delta*x(i+2*m)*((float(i)/float(n))**k4)
        g(i+2*m) = g(i+2*m) + delta*x(i)*((float(i)/float(n))**k4)
      end do  
        
     
        return
        end
*************************************************************        
                                        


cF58                             DIXMAANJ                              
*                             
*                    Initial point x0=[2.,2.,2...,2.].
*
        subroutine evalfg(n,x,f,g)
        real*8 x(n), f, g(n)
        real*8 alpha, beta, gamma, delta                       
        integer k1, k2, k3, k4
    
        alpha = 1.d0
        beta  = 0.0625d0
        gamma = 0.0625d0
        delta = 0.0625d0
                      
        k1 = 2
        k2 = 0
        k3 = 0
        k4 = 2
           
        m = n/3
*--       
        f = 1.d0
        do i=1,n
          f = f + alpha * x(i)*x(i)* ((float(i)/float(n))**k1)
        end do
        
        do i=1,n-1
          f = f + beta*x(i)*x(i)*((x(i+1)+x(i+1)*x(i+1))**2) *
     *            ((float(i)/float(n))**k2)
        end do
        
        do i=1,2*m
          f = f + gamma * x(i)*x(i) * (x(i+m)**4) *
     *            ((float(i)/float(n))**k3)
        end do
        
        do i=1,m
          f = f + delta * x(i) * x(i+2*m) *
     *            ((float(i)/float(n))**k4)
        end do

*-- Gradient

      do i=1,n
        g(i) =0.d0
      end do
        
      do i=1,n
        g(i) = g(i) + 2.d0*alpha*x(i)*((float(i)/float(n))**k1)  
      end do
      
      do i=1,n-1
        g(i) = g(i) + 2.d0*beta*x(i)*((x(i+1)+x(i+1)**2)**2)*
     *                ((float(i)/float(n))**k2)  
        g(i+1) = g(i+1) + beta*(x(i)**2)*2.d0*(x(i+1)+x(i+1)**2)*
     *                (1.d0+2.d0*x(i+1))*((float(i)/float(n))**k2)   
      end do
      
      do i=1,2*m
        g(i) = g(i) + 2.d0*gamma*x(i)*(x(i+m)**4)* 
     *                ((float(i)/float(n))**k3)      
        g(i+m) = g(i+m) + gamma*(x(i)**2)*4.d0*(x(i+m)**3)*
     *                ((float(i)/float(n))**k3)   
      end do
      
      do i=1,m
        g(i) = g(i) + delta*x(i+2*m)*((float(i)/float(n))**k4)
        g(i+2*m) = g(i+2*m) + delta*x(i)*((float(i)/float(n))**k4)
      end do  
        
     
        return
        end
*************************************************************        


   
cF59              
              
c@@@@@@@@--------------@@@@@@@@@@@@@@@---------------@@@@@@@@@@@@@@

c Last line.
