# [Maxima] RFC: extracting coefficients of a multivariate polynomial

Stavros Macrakis macrakis at alum.mit.edu
Thu Apr 24 12:45:58 CDT 2008

```For operations on polynomials, it is best to represent your
expressions in Canonical Rational Expression (CRE) form, which you do
using the rat(...) operation.  After that, ratcoeff(expr, var, degree)
is efficient, especially if the variable is the main variable of the
expression.  To choose the main variable, either use ratvars or
rat(..., var3, var2, var1), where var1 is the principal variable, e.g.

ex: rat((x+y+z)^3, z,y,x) =>
x^3+(3*y+3*z)*x^2+(3*y^2+6*z*y+3*z^2)*x+y^3+3*z*y^2+3*z^2*y+z^3
ratcoef(ex,x,1) => 3*z^2+6*y*z+3*y^2

rat((x+y+z)^3, x,y,z) =>
z^3+(3*y+3*x)*z^2+(3*y^2+6*x*y+3*x^2)*z+y^3+3*x*y^2+3*x^2*y+x^3

Try it out and let us know....

-s

On Thu, Apr 24, 2008 at 1:28 PM, andre maute <andre.maute at gmx.de> wrote:
>  I have to extract the coefficients of a multivariate polynomial.
>  The monomials appearing in the multivariate polynomial are given.
```