subroutine jfcn8(n, w, jf8)
implicit real(8) (a-h, o-z)
real(8) w(n), jf8(n,n)

jf8 =0.
x =w(1); y =w(2)
if( n>=3) z=w(3)

! Test1:
!f(1)=x*x +y*y -5.
!f(2)=y -exp(x) -1.

! jacobian:
!jf8(1,1) =2*x; jf8(1,2) =2*y
!jf8(2,1) =-exp(x); jf8(2,2) =1

!18-III
!f(1) =x+y+z*z-3.8
!f(2) =x*y*z+1.9
!f(3) =sqrt(x)+sqrt(y)-z*z-1.3

!jf(1,1) =1
!jf(1,2) =1
!jf(1,3) =2*z 

!jf(2,1) =y*z
!jf(2,2) =x*z
!jf(2,3) =x*y

!jf(3,1) =1./(2*sqrt(x))
!jf(3,2) =1./(2*sqrt(y))
!jf(3,3) =-2*z

! 19/I E: (2,1,-1)
!f(1) =x*x ++y*y +z*z-6.4
!f(2) =x*y*z +2.2
!f(3) =x +y-z*z-2.4

!jf(1,1) =2*x;   jf(1,2) =2*y;   jf(1,3) =2*z 
!jf(2,1) =y*z;   jf(2,2) =x*z;   jf(2,3) =x*y;

!jf(3,1) =1.;    jf(3,2) =1.;    jf(3,3) =-2*z

! Miel:
!f8(1) =2*x*x*x -y*y -1
!f8(2) =x*y*y*y -y -4

!jf8(1,1) =6*x*x;   jf8(1,2) =2*y;
!jf8(2,1) =y*Y*y;   jf8(2,2) =x*3*y*y -1;

! Vaahidi:
!pi =2*dasin(1.d0)
!f(1) =3*x1 -cos(x2*x3)- 0.5
!f(2) =x1*x1 -81*(x2 + 0.1)**2 +sin(x3) + 1.06
!f(3) =exp(-x1*x2) + 20*x3 + (10*pi-3)/3

x1 =w(1); x2 =w(2); x3 =w(3);

jf8(1,1) =3; jf8(1,2) =x3*dsin(x2*x3); jf8(1,3) =x2*dsin(x2*x3);
jf8(2,1) =2*x1; jf8(2,2) =-81*2*(x2 + 0.1); jf8(2,3) =dcos(x3);
jf8(3,1) =-x2*dexp(-x1*x2); jf8(3,2) =-x1*dexp(-x1*x2); jf8(3,3) =20;

END
