function poly_divide_test ( )

%*****************************************************************************80
%
%% poly_divide_test tests poly_divide.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    13 April 2009
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'poly_divide_test\n' );
  fprintf ( 1, '  poly_divide computes the quotient and\n' );
  fprintf ( 1, '  remainder for polynomial division.\n' );
  fprintf ( 1, '\n' );
%
%  1: Divide X^3 + 2*X^2 - 5*X - 6  by X-2.  
%     Quotient is 3+4*X+X^2, remainder is 0.
%
%  2: Divide X^4 + 3*X^3 + 2*X^2 - 2  by  X^2 + X - 3.
%     Quotient is X^2 + 2*X + 3, remainder 8*X + 7.
%
%  3: Divide X^3 - 2*X^2 + 0*X - 4  by  X - 3.
%     Quotient is X^2 + X + 3, remainder 5.
%
  ntest = 3;
  
  for test = 1 : ntest

    if ( test == 1 )
      na = 3;
      a(1:na+1) = [ -6.0, -5.0, 2.0, 1.0 ];
      nb = 1;
      b(1:nb+1) = [ -2.0, 1.0 ];
    elseif ( test == 2 )
      na = 4;
      a(1:na+1) = [ -2.0, 5.0, 2.0, 3.0, 1.0 ];
      nb = 2;
      b(1:nb+1) = [ -3.0, 1.0, 1.0 ];
    elseif ( test == 3 )
      na = 3;
      a(1:na+1) = [ -4.0, 0.0, -2.0, 1.0 ];
      nb = 1;
      b(1:nb+1) = [ -3.0, 1.0 ];
    end

    fprintf ( 1, '  The polynomial to be divided, A:\n' );
    r8poly_print ( a  );
    fprintf ( 1, '  The divisor polynomial, B:\n' );
    r8poly_print ( b );

    [ q, r ] = poly_divide ( a, b );
 
    fprintf ( 1, '  The quotient, Q:\n' );
    r8poly_print ( q  );
    fprintf ( 1, '  The remainder, R:\n' );
    r8poly_print ( r );

    fprintf ( 1, '  The product Q * B + R\n' );
    p = poly_multiply ( q, b );
    p = poly_add ( p, r );
    r8poly_print ( p );

  end

  return
end
