How to convert list into polynomial? reverse of args()
Subject: How to convert list into polynomial? reverse of args()
From: Stavros Macrakis
Date: Sun, 5 Feb 2006 16:25:28 -0500
> Thanks for the last answer. I need to convert a list into the polynomial.
> Basically I need to revert the operation of args() e.g.
> [f(x),f(y),f(z),....] convert to f(x)*f(y)*f(z)*... and the operator can
> be anything e.g. +,-,etc.
>
To convert a list of *coefficients* to a polynomial:
coeff: [3,4,5]$
sum(coeff[i+1]*x^i,i,0,length(coeff)-1);
=> 5*x^2+4*x+3
To convert a list of *terms* to a polynomial:
terms: [3, 4*x, 5*x^2 ]$
apply("+", terms)
or
sum(terms[i],i,1,length(terms))
To convert a list of *factors* to a polynomial:
factors: [(x-1), (x-3) ]$
apply("*", factors);
or
product(factors[i],i,1,length(factors))
You can expand the product with rat(...) or expand(...).