function kdv_exact_test ( )

%*****************************************************************************80
%
%% kdv_exact_test() tests kdv_exact().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 November 2023
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../kdv_exact' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'kdv_exact_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test kdv_exact().\n' );
%
%  The Octave manual gives useless incorrect information
%  on how to suppress the division by zero warning...
%
  warning ( 'off', 'division-by-zero' );

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

  rmpath ( '../kdv_exact' );

  return
end
function kdv_exact_rational_test ( )

%*****************************************************************************80
%
%% kdv_exact_rational_test() tests kdv_exact_rational().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 November 2023
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'kdv_exact_rational_test():\n' );
  fprintf ( 1, '  Test kdv_exact_rational().\n' );

  [ ~, ~, t0, tstop ] = kdv_parameters ( );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Parameters:\n' );
  fprintf ( 1, '    t0    = %g\n', t0 );
  fprintf ( 1, '    tstop = %g\n', tstop );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Evaluate solution and residual at selected points (X,T)\n' );
  
  x = linspace ( 0.0, 1.0, 6 );
  t = linspace ( t0, tstop, 6 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '      X       T       U(X,T)      Resid(X,T)\n' );
  fprintf ( 1, '\n' );
  for j = 1 : 6
    for i = 1 : 6
      if ( x(i) == 0.0 && t(j) == 0.0 )
        fprintf ( 1, '  %f  %f  *****  *****\n', x(i), t(j) );
      else
        [ u, ut, ux, uxx, uxxx ] = kdv_exact_rational ( x(i), t(j) );
        r = kdv_residual ( u, ut, ux, uxxx );
        fprintf ( 1, '  %f  %f  %f  %g\n', x(i), t(j), u, r );
      end
    end
    fprintf ( 1, '\n' );
  end

  return
end
function kdv_exact_sech_test ( )

%*****************************************************************************80
%
%% kdv_exact_sech_test() tests kdv_exact_sech().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 November 2023
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'kdv_exact_sech_test():\n' );
  fprintf ( 1, '  Test kdv_exact_sech().\n' );

  [ a, v, t0, tstop ] = kdv_parameters ( );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Parameters:\n' );
  fprintf ( 1, '    a     = %g\n', a );
  fprintf ( 1, '    v     = %g\n', v );
  fprintf ( 1, '    t0    = %g\n', t0 );
  fprintf ( 1, '    tstop = %g\n', tstop );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Evaluate solution and residual at selected points (X,T)\n' );
  
  x = linspace ( 0.0, 1.0, 6 );
  t = linspace ( t0, tstop, 6 );

  fprintf ( 1, '\n' );
  fprintf ( 1, '      X       T       U(X,T)      Resid(X,T)\n' );
  fprintf ( 1, '\n' );
  for j = 1 : 6
    for i = 1 : 6
      [ u, ut, ux, uxx, uxxx ] = kdv_exact_sech ( x(i), t(j) );
      r = kdv_residual ( u, ut, ux, uxxx );
      fprintf ( 1, '  %f  %f  %f  %g\n', x(i), t(j), u, r );
    end
    fprintf ( 1, '\n' );
  end

  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

