Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider the multivariable polynomial $$g(x,y,z,w)=a_1xyw+a_2xy^2+a_3xyz+a_4x^3z+a_5z^3+a_6y^2z+a_7w^4\;,$$ where $a_1,\cdots, a_7$ are constants. I would like to use Maple to extract the coefficients of all the terms of total degree 3 in the above expression. As a first step, I sorted the terms of the polynomial by total degree, using $>\mbox{sort}(g, '\mbox{tdeg}');$ but then I have no idea how to use coeff to collect the coefficients of interest. Any help is welcome!

share|cite|improve this question

Just do the following:





and you have got everything. There are also powerset methods, but I have no maple here to look them up.

share|cite|improve this answer
Upon trying what you suggested, this is what I get: Error, (in unkown) invalid input: coeff received x*w^2, which is not valid for its 2nd argument, x. – transcendental Nov 5 '12 at 19:13
Yes, I see the problem. Maple is shit. You need to replace the last command by this one: map(i->coeff(coeff(coeff(coeff(expand(p/i),x,0),y,0),z,0),w,0),varset); – sebigu Nov 5 '12 at 20:42
Hmmm. Would it be easier to simply truncate the polynomial to (total) degree 3? I would prefer that, now that I see what Maple's capabilities are. Another thing: how would you extract the coeff of x*w^2, for example? In the final analysis, I would like to know which coefficient goes with which 3rd degree term. – transcendental Nov 5 '12 at 21:09
You can easily save this. I do not know if maple can truncate polynomials, there is this algsubs command, but I really don't know. To save the monomial, do the following command: map(i->[coeff(coeff(coeff(coeff(expand(p/i),x,0),y,0),z,0),w,0),i],varset); – sebigu Nov 6 '12 at 8:36

I would replace each variable x by x*h, then do coeff(f,h,3);

f := randpoly([x,y,z],terms=30);
S := {seq(i=i*h, i=indets(f))};
g := subs(S, f);
g := coeff(g, h, 3);

Then get the coefficients with coeffs.

[coeffs(g, indets(g))];
share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.