function porous_medium_exact_test ( )

%*****************************************************************************80
%
%% porous_medium_exact_test() tests porous_medium_exact().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 May 2024
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../porous_medium_exact' );

  timestamp ( );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'porous_medium_exact_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s:\n', version ( ) );
  fprintf ( 1, '  Test porous_medium_exact(),\n' );
  fprintf ( 1, '  an exact solution of the porous medium equation.\n' );
%
%  Report the current parameter values.
%
  [ c, delta, m, t0, tstop ] = porous_medium_parameters ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  parameters:\n' );
  fprintf ( 1, '    c = %g\n', c );
  fprintf ( 1, '    delta = %g\n', delta );
  fprintf ( 1, '    m = %g\n', m );
  fprintf ( 1, '    t0 = %g\n', t0 );
  fprintf ( 1, '    tstop = %g\n', tstop );

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

  timestamp ( );

  rmpath ( '../porous_medium_exact' );

  return
end
function porous_medium_residual_test ( tstop )

%*****************************************************************************80
%
%% porous_medium_residual_test() tests porous_medium_residual().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    19 May 2024
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'porous_medium_residual_test():\n' );
  fprintf ( 1, '  Evaluate solution and residual at selected points (X,T)\n' );
  
  n = 11;
  m = 5;
  x = linspace ( -1.0, 1.0, n );
  t = linspace ( 0.0, 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, ux, uxx ] = porous_medium_exact ( x(i), t(j) );
      r = porous_medium_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 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

