function pendulum_ode23 ( )

%*****************************************************************************80
%
%% pendulum_ode23() tests pendulum_ode using ode23().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 May 2021
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pendulum_ode23:\n' );
  fprintf ( 1, '  Test pendulum_ode using ode23.\n' );

  [ g, l, m, t0, y0, tstop ] = pendulum_parameters ( );

  f = @ pendulum_deriv;
  tspan = [ t0, tstop ];
  [ t, y ] = ode23 ( f, tspan, y0 );

  ye = pendulum_exact ( t );
%
%  Plot u = theta.
%
  figure ( 1 );
  clf ( );
  plot ( t, y(:,1), 'ro', ...
         t, ye(:,1), 'b-', 'linewidth', 2 );
  grid ( 'on' );
  xlabel ( '<-- Time -->' );
  ylabel ( '<-- Angular deflection (radians) -->' );
  title ( 'Linear pendulum, theta: ode23' );
  legend ( 'ode23', 'exact' );
  filename = 'pendulum_ode23_theta.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
%
%  Plot v = thetadot.
%
  figure ( 2 );
  clf ( );
  plot ( t, y(:,2), 'ro', ...
         t, ye(:,2), 'b-', 'linewidth', 2 );
  grid ( 'on' );
  xlabel ( '<-- Time -->' );
  ylabel ( '<-- Angular velocity (radians/sec) -->' );
  title ( 'Linear pendulum, thetadot: ode23' );
  legend ( 'ode23', 'exact' );
  filename = 'pendulum_ode23_thetadot.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
%
%  Plot energy.
%
  h = pendulum_conserved ( y );

  figure ( 3 );
  clf ( );
  hold ( 'on' );
    plot ( t, h, 'b-', 'linewidth', 2 );
    plot ( [t(1), t(end) ], [ 0.0, 0.0 ], 'k-', 'linewidth', 2 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<-- Time -->' );
  ylabel ( '<-- Energy -->' );
  title ( 'Energy conservation: ode23' );
  filename = 'pendulum_ode23_energy.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );

  return
end

