function arenstorf_ode45 ( )

%*****************************************************************************80
%
%% arenstorf_ode45() solves arenstorf_ode() using ode45().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 June 2021
%
%  Author:
%
%    John Burkardt
%
  [ mu1, mu2, t0, xy0, tstop ] = arenstorf_parameters ( );

  tspan = [ t0, tstop ];
  sol = ode45 ( @arenstorf_deriv, tspan, xy0 );

  nt = 101;
  t = linspace ( t0, tstop, nt );
  xy = deval ( sol, t );

  figure ( );
  hold ( 'on' )
  plot ( xy(1,:), xy(2,:), 'linewidth', 2 );
  plot ( xy(1,1), xy(2,1), 'g.', 'markersize', 25 );
  plot ( xy(1,end), xy(2,end), 'r.', 'markersize', 25 );
  hold ( 'off' )
  grid ( 'on' );
  xlabel ( '<---  q1  --->' );
  ylabel ( '<---  q2  --->' );
  title ( 'arenstorf_ode(): ode45() phase plot' )
  filename = 'arenstorf_ode45_phase.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  h = arenstorf_conserved ( xy );

  figure ( );
  clf ( );
  hold ( 'on' );
    plot ( t, h, 'r-', 'linewidth', 3 );
    plot ( tspan, [h(1), h(1) ], 'k:', 'linewidth', 3 );
    plot ( tspan, [0.0, 0.0 ], 'k--', 'linewidth', 3 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<-- T -->', 'Fontsize', 16 );
  ylabel ( '<-- H(T) -->', 'Fontsize', 16 );
  legend ( 'Computed Energy', 'Initial Energy', 'Zero Energy' );
  title ( 'arenstorf_ode(): ode45: conservation', 'fontsize', 24 );
  filename = 'arenstorf_ode45_conservation.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end

