function kepler_ode45 ( tspan, pq0 )

%*****************************************************************************80
%
%% kepler_ode45 uses ode45() to solve the Kepler problem.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    21 March 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'kepler_ode45_test:\n' );
  fprintf ( 1, '  Use ode45 to solve the Kepler problem.\n' );

  f = @ kepler_deriv;

  [ t, pq ] = ode45 ( f, tspan, pq0 );

  figure ( 1 );
  clf ( );
  hold ( 'on' );
  plot ( t, pq(:,1), 'r-', 'linewidth', 2 );
  plot ( t, pq(:,2), 'g-', 'linewidth', 2 );
  plot ( t, pq(:,3), 'b-', 'linewidth', 2 );
  plot ( t, pq(:,4), 'm-', 'linewidth', 2 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<---  t  --->' );
  ylabel ( '<---  p,q  --->' );
  title ( 'ode45: Kepler Time Plot', 'fontsize', 24 )
  legend ( 'P', 'P''', 'Q', 'Q''' );
  filename = 'kepler_ode45_plot.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  figure ( 2 );
  plot ( pq(:,1), pq(:,2) );
  grid ( 'on' );
  xlabel ( '<---  q1  --->' );
  ylabel ( '<---  q2  --->' );
  title ( 'ode45: Kepler Phase Plot', 'fontsize', 24 )
  filename = 'kepler_ode45_phase.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  h = kepler_conserved ( pq );

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

  return
end
