function polynomial_resultant_symbolic_test ( )

%*****************************************************************************80
%
%% polynomial_resultant_symbolic_test() tests resultant().
%
%  Discussion:
%
%    resultant(p,q) computes the resultant of the polynomials p and q.
%    The polynomials are stored as symbolic variables.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    31 January 2024
%
%  Author:
%
%    John Burkardt
%
  syms x;

  timestamp ( );

  fprintf ( 1, '\n' )
  fprintf ( 1, 'polynomial_resultant_symbolic_test():\n' )
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test resultant(p,q) for symbolic polynomials p and q.\n' );
  fprintf ( 1, '\n' )

  for i = 1 : 7

    if ( i == 1 )
      p = sym ( 1 );
      q = sym ( 2 );
      r1 = 1;
    elseif ( i == 2 )
      p = 3*x + 3;
      q = x^2 + 2*x + 1;
      r1 = 0;
    elseif ( i == 3 )
      p = x^3 + 3*x^2 + 3*x + 1;
      q = x^2 - 1;
      r1 = 0;
    elseif ( i == 4 )
      p = x^3 + 2*x^2 + 3*x + 4;
      q = 5*x^2 + 6*x + 7;
      r1 = 832;
    elseif ( i == 5 )
      p = x^3 + 2*x^2 + 3*x + 4;
      q = 4*x^3 + 3*x^2 + 2*x + 1;
      r1 = - 2000;
    elseif ( i == 6 )
      p = x^4 - 4*x^3 + 5*x^2 - 2*x;
      q = x^4 - 4*x^3 + 5*x^2 - 2*x + 1;
      r1 = 1;
    elseif ( i == 7 )
      p = x^4 - 4*x^3 + 5*x^2 + -2*x;
      q = x^7 - 12*x^6 + 60*x^5 - 160*x^4 + 240*x^3 - 192*x^2 + 64*x;
      r1  = 0;
    end

    r2 = resultant ( p, q );
    fprintf ( 1, '\n' );
    fprintf ( 1, 'p(x) = %s\n', char ( p ) );
    fprintf ( 1, 'q(x) = %s\n', char ( q ) );
    fprintf ( 1, 'r (tabulated)  = %g\n', r1 );
    fprintf ( 1, 'r (calculated) = %g\n',  r2 );

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

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 November 2022
%
%  Author:
%
%    John Burkardt
%
  t = now ( );
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

