Energy minimization in the 4 body problem.

%--------------------------------------------------------------------------
%   Copyright (c) 2018 Princeton Satellite Systems, Inc.
%   All rights reserved.
%--------------------------------------------------------------------------
%   Since 2018.1
%--------------------------------------------------------------------------

% Initialize the Earth-Moon-Sun system
id = PlanetId({'sun' 'earth' 'moon'});

PlanetPositionEMBarycenter('initialize',id);

elements  = [ 7500,-0.217530192869796,2.603015172762677,2.458919562241475,...
              0.000833001950028,3.167868666564607];
dV1       = 2.991189123761749;
dtTarg    = 8.673098911506269e+06;
muMoon    = 4.902793384008800e+03;
p         = 6.434127000571430e+04;
jDate     = JD2000+1;

figH1     = PlotLET(elements,dV1,dtTarg+2*7*86400,jDate);
set(figH1(1),'name',strcat(get(figH1(1),'name'),' BEFORE'))
set(figH1(2),'name',strcat(get(figH1(2),'name'),' BEFORE'))

[elements,dV1,det,f,jTraj,jL2] = MinE4BP(elements,dV1,dtTarg,0,muMoon,p,jDate);
figH2     = PlotLET(elements,dV1,det+3*86400,jDate);
set(figH2(1),'name',strcat(get(figH2(1),'name'),' AFTER'))
set(figH2(2),'name',strcat(get(figH2(2),'name'),' AFTER'))

%--------------------------------------
 
Exiting: Maximum number of iterations has been exceeded
         - increase MaxIter option.
         Current function value: -0.089839