function arenstorf_ode_test ( )

%*****************************************************************************80
%
%% arenstorf_ode_test tests arenstorf_ode().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    08 February 2020
%
%  Author:
%
%    John Burkardt
%
%  Local:
%
%    real E: the eccentricity.
%
  addpath ( '../arenstorf_ode' )

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'arenstorf_ode_test:\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test arenstorf_ode using ode45.\n' );
%
%  Note that after 17.5, the ode45 solution fails to close the loop.
%
  [ mu1, mu2, t0, xy0 ] = arenstorf_parameters ( )

  tmax = 17.0652165601579625588917206249;

  odeset ( 'RelTol', 0.1E-8 );

  tspan = [ t0, tmax ];
  [ t, xy ] = ode45 ( @arenstorf_deriv, tspan, xy0 );

  figure ( );
  hold ( 'on' )
  plot ( xy(:,1), xy(:,2) );
  plot ( xy(1,1), xy(1,2), 'g.', 'markersize', 25 );
  plot ( xy(end,1), xy(end,2), 'r.', 'markersize', 25 );
  hold ( 'off' )
  grid ( 'on' );
  xlabel ( '<---  q1  --->' );
  ylabel ( '<---  q2  --->' );
  title ( 'Arenstorf phase plot' )
  filename = 'arenstorf_ode_phase.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'arenstorf_ode_test:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../arenstorf_ode' )

  return
end
