function c3 = r8poly_multiply ( d1, c1, d2, c2 )

%*****************************************************************************80
%
%% r8poly_multiply() computes the product of two real polynomials.
%
%  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 MIT license. 
%
%  Modified:
%
%    20 October 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer D1: the degree of the first polynomial.
%
%    real C1(1:D1+1): the coefficients of the first polynomial.
%
%    integer D2: the degree of the second polymonial.
%
%    real C2(1:D2+1): the coefficients of the second polymonial.
%
%  Output:
%
%    real C3(1:D1+D2+1), the coefficients of the product.
%
  c1 = c1(:);
  c2 = c2(:);

  c3 = zeros ( d1 + d2 + 1, 1 );
  
  for i = 0 : d1
    c3(i+1:i+d2+1) = c3(i+1:i+d2+1) + c1(i+1) * c2(1:d2+1);
  end

  return
end
