function vanderpol_ode_period_test ( )

%*****************************************************************************80
%
%% vanderpol_ode_period_test() solves vanderpol_ode_period().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    26 April 2021
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../vanderpol_ode_period' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'vanderpol_ode_period_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Solve vanderpol_ode() for parameter MU\n' );
  fprintf ( 1, '  and estimate the period P.\n' );
%
%  Get the default parameter values.
%
  [ mu, t0, y0, tstop ] = vanderpol_parameters ( );

  fprintf ( 1, '\n' );
  fprintf ( 1, '        Mu     Periods     P(obs)    P(predicted)     TStop\n' );
  fprintf ( 1, '\n' );
%
%  For Octave, remove MU = 1000, because Octave is too slow!
%
  for mu = [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0, 100.0 ]
%
%  Estimate the period, so we can set TSTOP to at least 5 periods.
%
    p_predict = vanderpol_period ( mu );
    tstop = max ( 100.0, 5.0 * p_predict );
%
%  Update MU and TSTOP.
%
    vanderpol_parameters ( mu, t0, y0, tstop );
%
%  Solve the ODE.
%
    [ p, np ] = vanderpol_period_ode45 ( );

    fprintf ( 1, '  %8.0f  %4d  %11.5g  %11.5g  %11.5g\n', mu, np, p, p_predict, tstop );

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

  timestamp ( );

  rmpath ( '../vanderpol_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

