function pendulum_angle_euler ( n, theta0 )

%*****************************************************************************80
%
%% pendulum_angle_euler compares linear and nonlinear pendulum solutions.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    04 November 2019
%
%  Author:
%
%    John Burkardt
%
  if ( nargin < 1 )
    n = input ( 'Enter the number of timesteps n: ' );
  end

  if ( nargin < 2 )
    theta0 = input ( 'Enter the desired initial angle theta0: ' );
  end

  a = 0.0;
  b = 6.0 * pi;
  u = theta0;
  v = 0.0;
  y0 = [ u, v ];
  
  [ t, y1 ] = euler ( @(t,y)pendulum_prime(t,y), n, a, b, y0 );
  [ t, y2 ] = euler ( @(t,y)pendulum_nonlinear_prime(t,y), n, a, b, y0 );

  figure ( 1 )
  clf ( );
  hold ( 'on' );
  plot ( t, y1, 'r-', 'linewidth', 3 );
  plot ( t, y2, 'b-', 'linewidth', 3 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<-- T -->' );
  ylabel ( '<-- Y(T) -->' );
  label = sprintf ( 'linear/nonlinear pendulum, theta0 = %g\n', theta0 );
  title ( label );
  filename = 'pendulum_angle_plot.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  figure ( 2 )
  clf ( );
  hold ( 'on' );

  plot ( y1(:,1), y1(:,2), 'm-', 'linewidth', 3 );
  plot ( y1(1,1), y1(1,2), 'go', 'markersize', 40 );
  plot ( y1(end,1), y1(end,2), 'ro', 'markersize', 30 );

  plot ( y2(:,1), y2(:,2), 'b-', 'linewidth', 3 );
  plot ( y2(1,1), y2(1,2), 'g.', 'markersize', 40 );
  plot ( y2(end,1), y2(end,2), 'r.', 'markersize', 30 );

  hold ( 'off' );
  grid ( 'on' );
  axis ( 'equal' );
  xlabel ( '<-- Theta -->' );
  ylabel ( '<-- dThetadT -->' );
  label = sprintf ( 'linear/nonlinear pendulum, theta0 = %g\n', theta0 );
  title ( label );
  filename = 'pendulum_angle_phase.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

  return
end
  
