function [fxx,grad] = funcgrad(xx,mue)
%
%  Evaluation of vector field and gradient of Jacobi integral.
%
%  input:
% 	xx(N,4)	(intval) points of pseudo orbit
% 	mue		(intval) mass ratio of primaries
%
%  output:
% 	fxx(N,4)	(intval) vector field at xx
% 	grad(N,16)	(intval) gradient of Jacobi integral
%
mu2=mue;
mu1=1-mu2;
R1=(xx(:,1)+mu2).^2+xx(:,2).^2;
R2=(xx(:,1)-mu1).^2+xx(:,2).^2;
r1=sqrt(R1); r2=sqrt(R2);
aa=xx(:,1) - mu1*(xx(:,1)+mu2)./(r1.^3) - mu2*(xx(:,1)-mu1)./(r2.^3);
bb=xx(:,2) - mu1*xx(:,2)./(r1.^3) - mu2*xx(:,2)./(r2.^3);
fxx=[ xx(:,3), xx(:,4), aa+2*xx(:,4), bb-2*xx(:,3) ];
grad=[ aa, bb, -xx(:,3), -xx(:,4) ];

return

%
% written   Sept/10/02   D.Stoffer
%




