# [Maxima] coefficients of a polynomial in two or more variables

Christian Stengg christian.stengg at gmx.at
Sat Dec 5 09:06:38 CST 2009

```Hello,

I have experimented on your suggestions and came across the following problem:

(%i1) p1:a*x^2+b*x*y+c*y^2+d*x+e*y+f;
ratcoef(p1,x*y);
hipow(p1,x*y);
bothcoef(p1,x*y);
hipow(p1,b*x*y);
bothcoef(p1,b*x*y);
(%o1) c*y^2+b*x*y+e*y+a*x^2+d*x+f
(%o2) b
(%o3) 0
(%o4) [0,c*y^2+b*x*y+e*y+a*x^2+d*x+f]
(%o5) 1
(%o6) [1,c*y^2+e*y+a*x^2+d*x+f]

ratcoef recognizes x*y as "partial monomial", whereas hipow and bothcoef don't. This means that

[d,eq]: bothcoef(eq,kn)

d : ratcoef(eq, kn),
eq : eq - d * kn,

does not work.

It seems to me that hipow und bothcoef only work for "full subexpressions". Is this different behaviour of ratcoef, hipow and bothcoef intended? Can someone explain me the reason for it?

With the sum x+y instead of the product x*y hipow und bothcoef work as I would expect it:

(%i7) p2:a*(x+y)^2+b*(x+y)+c;
ratcoef(p2,x+y);
hipow(p2,x+y);
bothcoef(p2,x+y);
(%o7) a*(y+x)^2+b*(y+x)+c
(%o8) b
(%o9) 2
(%o10) [b,a*(y+x)^2+c]