function r8poly_print ( a )

%*****************************************************************************80
%
%% R8POLY_PRINT prints out a polynomial.
%
%  Discussion:
%
%    The power sum form of a polynomial is:
%
%      p(x) = c(0) + c(1) * x + ... + c(n-1) * x^(n-1) + c(n) * x^(n)
%
%    Because MATLAB doesn't allow 0 indexing, we use an adjusted formula:
%
%      p(x) = c(1) + c(2) * x + ... + c(n) * x^(n-1) + c(n+1) * x^(n)
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license. 
%
%  Modified:
%
%    07 October 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real A(1:D+1): the polynomial coefficients.
%    A(1) is the constant term and
%    A(I+1) is the coefficient of X^I.
%
  d = length ( a ) - 1;

  fprintf ( 1, '\n' );

  if ( d < 0 )
    fprintf ( 1, '  p(x) = Null polynomial of degree %d\n', d );
    return
  end

  first = true;

  for i = d : -1 : 0

    if ( a(i+1) < 0.0 )
      plus_minus = '-';
    else
      plus_minus = '+';
    end

    mag = abs ( a(i+1) );

    if ( mag ~= 0.0 )

      if ( first )
        fprintf ( '  p(x) = ' );
        if ( plus_minus == '+' )
          plus_minus = ' ';
        end
        first = false;
      else
        fprintf ( '         ' );
      end

      if ( 2 <= i )
        fprintf ( 1, '%c%14f * x^%d\n', plus_minus, mag, i );
      elseif ( i == 1 )
        fprintf ( 1, '%c%14f * x\n', plus_minus, mag );
      elseif ( i == 0 )
        fprintf ( 1, '%c%14f\n', plus_minus, mag );
      end

    end

  end

  return
end
