function mackey_glass_dde_test ( )

%*****************************************************************************80
%
%% mackey_glass_dde_test() tests mackey_glass().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 September 2021
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../mackey_glass_dde' )

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'mackey_glass_dde_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Solve Mackey Glass DDE\n' );

  [ gamma, beta, n, tau t0, y0, tstop ] = mackey_glass_parameters ( );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Parameter values:\n' );
  fprintf ( 1, '    gamma = %g\n', gamma );
  fprintf ( 1, '    beta  = %g\n', beta );
  fprintf ( 1, '    n     = %g\n', n );
  fprintf ( 1, '    tau   = %g\n', tau );
  fprintf ( 1, '    t0    = %g\n', t0 );
  fprintf ( 1, '    y0    = (%g,%g,%g,%g)\n', y0 );
  fprintf ( 1, '    tstop = %g\n', tstop );

  tspan = [ t0; tstop ];
  sol = dde23 ( @ mackey_glass_dde, tau, @ mackey_glass_history, tspan );
%
%  Sample solution and derivative at equally spaced points.
%
  t = linspace ( t0, tstop, 1001 )
  [ y, yp ] = deval ( sol, t )
%
%  Plot y(t), y(t-tau), y'(t-tau).
%  Since tau = 2, and dt = 0.1, we need to jump back by 20.
%
  plot3 ( y(21:1001), y(1:981), yp(1:981), '-' );
  xlabel ( '<-- y -->' );
  ylabel ( '<-- ylag -->' );
  zlabel ( '<-- ylag'' -->' );
  title ( 'Mackey Glass DDE' );
  print ( '-dpng', 'mackey_glass.png' );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'mackey_glass_dde_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../mackey_glass_dde' )

  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

