function henon_heiles_euler ( tspan, w0, n )

%*****************************************************************************80
%
%% henon_heiles_euler uses euler() to solve the Henon Heiles problem.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 April 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'henon_heiles_euler_test:\n' );
  fprintf ( 1, '  Use euler to solve the Henon Heiles problem.\n' );

  [ t, w ] = euler ( @henon_heiles_deriv, tspan, w0, n );

  figure ( 1 );
  clf ( );
  hold ( 'on' );
  plot ( t, w(:,1), 'r-', 'linewidth', 2 );
  plot ( t, w(:,2), 'g-', 'linewidth', 2 );
  plot ( t, w(:,3), 'b-', 'linewidth', 2 );
  plot ( t, w(:,4), 'm-', 'linewidth', 2 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<---  t  --->' );
  ylabel ( '<---  p,q  --->' );
  title ( 'euler: Henon Heiles Time Plot', 'fontsize', 16 )
  legend ( 'X', 'X''', 'Y', 'Y''' );
  filename = 'henon_heiles_euler_plot.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  figure ( 2 );
  plot ( w(:,1), w(:,3) );
  grid ( 'on' );
  xlabel ( '<---  q1  --->' );
  ylabel ( '<---  q2  --->' );
  title ( 'euler: Henon Heiles Orbit', 'fontsize', 16 )
  filename = 'henon_heiles_euler_orbit.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  h = henon_heiles_conserved ( w );

  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', 16 );
  filename = 'henon_heiles_euler_conserved.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
