function [ n_data, p, q, r ] = polynomial_resultant_values ( n_data )

%*****************************************************************************80
%
%% polynomial_resultant_values() returns polynomial resultants.
%
%  Discussion:
%
%    Each call to this routine returns two polynomials P and Q,
%    defined by their coefficient vectors, with the constant
%    coefficient first, such that
%
%      resultant ( p, q ) = r
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    30 January 2024
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer n_data: the user sets N_DATA to 0 before the first call.  
%    Thereafter, it should simply be the value returned by the previous call.
%
%  Output:
%
%    integer n_data: the routine increments the input value of N_DATA by 1. 
%    But when there is no more data, the output value of N_DATA will be 0.
%
%    real p(np): the first polynomial.
%
%    real q(nq): the second polynomial.
%
%    real r: the resultant.
%
  n_max = 7;

  if ( n_data < 0 )
    n_data = 0;
  end

  n_data = n_data + 1;

  if ( n_max < n_data )

    n_data = 0;
    p = [];
    q = [];
    r = 0.0;

  elseif ( n_data == 1 )

    p = [ 1 ];
    q = [ 2 ];
    r = 1;

  elseif ( n_data == 2 )

    p = [ 3, 3 ];
    q = [ 1, 2, 1 ];
    r = 0;

  elseif ( n_data == 3 )

    p = [ 1, 3, 3, 1 ];
    q = [ -1, 0, 1 ];
    r = 0;

  elseif ( n_data == 4 )

    p = [ 4, 3, 2, 1 ];
    q = [ 7, 6, 5 ];
    r = 832;

  elseif ( n_data == 5 )

    p = [ 4, 3, 2, 1 ];
    q = [ 1, 2, 3, 4 ];
    r = -2000;

  elseif ( n_data == 6 )

    p = [ 0, -2, 5, -4, 1 ];
    q = [ 1, -2, 5, -4, 1 ];
    r = 1;

  elseif ( n_data == 7 )

    p = [ 0, -2, 5, -4, 1 ];
    q = [ 0, 64, -192, 240, -160, 60, -12, 1 ];
    r = 0;

  end

  return
end
