function pendulum_ode_period_test ( )

%*****************************************************************************80
%
%% pendulum_ode_period_test() computes the period of the pendulum ODE.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    21 December 2021
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../pendulum_ode_period' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pendulum_ode_period_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Estimate the period of the pendulum ODE.\n' );

%
%  Restore the default parameter values.
%
  g = 9.81;
  l = 1.0;
  m = 1.0;
  t0 = 0.0;
  y0 = [ pi/3.0, 0.0 ];
  tstop = 20.0;
  pendulum_parameters ( g, l, m, t0, y0, tstop );
%
%  Vary g.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '          G          L          M    NP       Pobs     Predic      Tstop          H\n' );
  fprintf ( 1, '\n' );

  for g = [ 1.0, 5.0, 9.81, 20.0, 50.0 ]
%
%  Update parameters.
%
    pendulum_parameters ( g, l, m, t0, y0, tstop );
%
%  Predict period.
%
    p_predict = pendulum_period ( );
%
%  Get energy H.
%
    h = pendulum_conserved ( y0 );
%
%  Solve the ODE.
%
    [ p_obs, np ] = pendulum_ode_period_ode45 ( );

    fprintf ( 1, '  %9.4g  %9.4g  %9.4g  %4d  %9.4g  %9.4g  %9.4g  %9.4g\n', ...
      g, l, m, np, p_obs, p_predict, tstop, h );

  end
%
%  Restore the default parameter values.
%
  g = 9.81;
  l = 1.0;
  m = 1.0;
  t0 = 0.0;
  y0 = [ pi/3.0, 0.0 ];
  tstop = 20.0;
  pendulum_parameters ( g, l, m, t0, y0, tstop );
%
%  Vary l.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '          G          L          M    NP       Pobs     Predic      Tstop          H\n' );
  fprintf ( 1, '\n' );

  for l = [ 0.25, 0.5, 1.0, 2.0, 16.0 ]
%
%  Update parameters.
%
    pendulum_parameters ( g, l, m, t0, y0, tstop );
%
%  Predict period.
%
    p_predict = pendulum_period ( );
%
%  Get energy H.
%
    h = pendulum_conserved ( y0 );
%
%  Solve the ODE.
%
    [ p_obs, np ] = pendulum_ode_period_ode45 ( );

    fprintf ( 1, '  %9.4g  %9.4g  %9.4g  %4d  %9.4g  %9.4g  %9.4g  %9.4g\n', ...
      g, l, m, np, p_obs, p_predict, tstop, h );

  end
%
%  Restore the default parameter values.
%
  g = 9.81;
  l = 1.0;
  m = 1.0;
  t0 = 0.0;
  y0 = [ pi/3.0, 0.0 ];
  tstop = 20.0;
  pendulum_parameters ( g, l, m, t0, y0, tstop );
%
%  Vary m.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '          G          L          M    NP       Pobs     Predic      Tstop          H\n' );
  fprintf ( 1, '\n' );

  for m = [ 0.25, 0.5, 1.0, 2.0, 16.0 ]
%
%  Update parameters.
%
    pendulum_parameters ( g, l, m, t0, y0, tstop );
%
%  Predict period.
%
    p_predict = pendulum_period ( );
%
%  Get energy H.
%
    h = pendulum_conserved ( y0 );
%
%  Solve the ODE.
%
    [ p_obs, np ] = pendulum_ode_period_ode45 ( );

    fprintf ( 1, '  %9.4g  %9.4g  %9.4g  %4d  %9.4g  %9.4g  %9.4g  %9.4g\n', ...
      g, l, m, np, p_obs, p_predict, tstop, h );

  end
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pendulum_ode_period_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../pendulum_ode_period' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

