function traveling_wave_exact_test ( )

%*****************************************************************************80
%
%% traveling_wave_exact_test() tests traveling_wave_exact().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 April 2025
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../traveling_wave_exact' );

  timestamp ( );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'traveling_wave_exact_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s:\n', version ( ) );
  fprintf ( 1, '  Test traveling_wave_exact(),\n' );
  fprintf ( 1, '  an exact traveling wave solution of the wave equation.\n' );
%
%  Report the current parameter values.
%
  [ a, k, w, phi, xmin, xmax, t0, tstop ] = traveling_wave_parameters ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  parameters:\n' );
  fprintf ( 1, '    a     = %g\n', a );
  fprintf ( 1, '    k     = %g\n', k );
  fprintf ( 1, '    w     = %g\n', w );
  fprintf ( 1, '    phi   = %g\n', phi );
  fprintf ( 1, '    xmin  = %g\n', xmin );
  fprintf ( 1, '    xmax  = %g\n', xmax );
  fprintf ( 1, '    t0    = %g\n', t0 );
  fprintf ( 1, '    tstop = %g\n', tstop );

  traveling_wave_residual_test ( );

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

  timestamp ( );

  rmpath ( '../traveling_wave_exact' );

  return
end
function traveling_wave_residual_test ( )

%*****************************************************************************80
%
%% traveling_wave_residual_test() tests traveling_wave_residual().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 April 2025
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'traveling_wave_residual_test():\n' );
  fprintf ( 1, '  Evaluate solution and residual at selected points (X,T)\n' );
  
  [ a, k, w, phi, xmin, xmax, t0, tstop ] = traveling_wave_parameters ( );

  n = 11;
  m = 5;
  x = linspace ( xmin, xmax, n );
  t = linspace ( t0, tstop, m );

  fprintf ( 1, '\n' );
  fprintf ( 1, '      X       T       U(X,T)      Resid(X,T)\n' );
  fprintf ( 1, '\n' );
  for j = 1 : m
    for i = 1 : n
      [ u, ut, utt, ux, uxx ] = traveling_wave_exact ( x(i), t(j) );
      r = traveling_wave_residual ( x(i), t(j) );
      fprintf ( 1, '  %8.4f  %8.4f  %10.4g  %g\n', x(i), t(j), u, r );
    end
    fprintf ( 1, '\n' );
  end

  return
end
function traveling_wave_plot ( )

%*****************************************************************************80
%
%% traveling_wave_plot() tests the traveling wave.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 April 2025
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'traveling_wave_plot():\n' );
  fprintf ( 1, '  Plot the traveling wave over several time steps\n' );
  
  [ a, k, w, phi, xmin, xmax, t0, tstop ] = traveling_wave_parameters ( );

  n = 51;
  m = 5;
  x = linspace ( xmin, xmax, n );
  t = linspace ( t0, tstop, m );
  
  hold ( 'on' );
  grid ( 'on' );
  for i = 1 : m
    [ u, ut, utt, ux, uxx ] = traveling_wave_exact ( x, t(i) );
    plot ( x, u, 'linewidth', 2 );
  end
  hold ( 'off' );
  title ( 'Traveling wave' );
  filename = 'traveling_wave_exact.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );
  
  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

