function kepler_euler ( tspan, pq0, n )

%*****************************************************************************80
%
%% kepler_euler uses euler() to solve the Kepler problem.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    26 February 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'kepler_euler_test:\n' );
  fprintf ( 1, '  Use euler to solve the Kepler problem.\n' );

  f = @ kepler_deriv;

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

  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 ( 'euler: Kepler Time Plot', 'fontsize', 24 )
  legend ( 'P', 'P''', 'Q', 'Q''' );
  filename = 'kepler_euler_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 ( 'euler: Kepler Phase Plot', 'fontsize', 24 )
  filename = 'kepler_euler_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 ( 'euler: H(T) conservation', 'fontsize', 24 );
  filename = 'kepler_euler_conserved.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
