function pendulum_elastic_ode23 ( )

%*****************************************************************************80
%
%% pendulum_elastic_ode23() tests pendulum_elastic_ode using ode23.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 April 2021
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pendulum_elastic_ode23():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Use ode23() to solve the elastic pendulum ODE.\n' );

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

  f = @ pendulum_elastic_deriv;
  tspan = [ t0, tstop ];

  [ t, y ] = ode23 ( f, tspan, y0 );

  n = length ( t );
  fprintf ( 1, '  Number of adaptive steps N = %d\n', n );
%
%  Plot theta, dtheta/dt.
%
  figure ( 1 );
  clf ( );
  hold ( 'on' );
    plot ( t, y(:,1), 'r-', 'linewidth', 2 );
    plot ( t, y(:,2), 'b-', 'linewidth', 2 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<-- Time -->' );
  ylabel ( '<-- Theta, dTheta/dT -->' );
  title ( 'nonlinear pendulum, ode23: angular deflection.' );
  legend ( 'Theta', 'dTheta/dT' );
  filename = 'pendulum_elastic_ode23_theta.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
%
%  Theta phase
%
  figure ( 2 );
  clf ( );
  plot ( y(:,1), y(:,2), 'r-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- Theta -->' );
  ylabel ( '<-- ThetaDot -->' );
  title ( 'nonlinear pendulum, ode23: theta phase.' );
  filename = 'pendulum_elastic_ode23_theta_phase.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
%
%  Plot Nu, dNu/dT
%
  figure ( 3 );
  clf ( );
  hold ( 'on' );
    plot ( t, y(:,3), 'r-', 'linewidth', 2 );
    plot ( t, y(:,4), 'b-', 'linewidth', 2 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<-- Time -->' );
  ylabel ( '<-- Nu, dNu/dT -->' );
  title ( 'nonlinear pendulum, ode23: relative strain.' );
  legend ( 'Nu', 'dNu/dT' );
  filename = 'pendulum_elastic_ode23_nu.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
%
%  Theta phase
%
  figure ( 4 );
  clf ( );
  plot ( y(:,3), y(:,4), 'r-', 'linewidth', 3 );
  grid ( 'on' );
  xlabel ( '<-- Nu -->' );
  ylabel ( '<-- NuDot -->' );
  title ( 'nonlinear pendulum, ode23: nu phase.' );
  filename = 'pendulum_elastic_ode23_nu_phase.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
%
%  Plot energy.
%
  h = pendulum_elastic_conserved ( y );

  figure ( 5 );
  clf ( );
  hold ( 'on' );
    plot ( t, h, 'r-', 'linewidth', 3 );
    plot ( [ t0, tstop ], [ h(1), h(1) ], 'b--', 'linewidth', 2 );
    plot ( [ t0, tstop ], [ 0.0, 0.0 ], 'k-', 'linewidth', 2 );
  hold ( 'off' );
  grid ( 'on' );
  xlabel ( '<-- Time -->' );
  ylabel ( '<-- Energy -->' );
  title ( 'nonlinear pendulum, ode23: energy' );
  filename = 'pendulum_elastic_ode23_energy.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved in "%s"\n', filename );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pendulum_elastic_ode23:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end
