function [n,xv,fvec,fjac,ldfjac,iflag]=c05fj(n,xv,fvec,fjac,ldfjac,iflag)
x = xv(1)   ;
y = xv(2)   ;
z = xv(3)   ;
if iflag ~=2
  fvec(1) = z^2-x^2-y^2+2*x+2*z-1   ;
  fvec(2) = y*z-y-x+1   ;
  fvec(3) = -2+x+y   ;
else
  fjac(1,1) = -2*x+2   ;
  fjac(1,2) = -2*y   ;
  fjac(1,3) = 2*z+2   ;
  fjac(2,1) = -1   ;
  fjac(2,2) = z-1   ;
  fjac(2,3) = y   ;
  fjac(3,1) = 1   ;
  fjac(3,2) = 1   ;
  fjac(3,3) = 0   ;
end
