# Reducing a multi-variate polynomial to have terms upto certain degree

I have a polynomial in x and y. I want to keep all the terms with (combined) degree 4. Any pointers will be appreciated. Simple tricks for doing the same with univariate polynomial don't seem to work.

-
PolynomialReduce[(poly/.Thread[vars->t*vars],t^5][[2]]/.t->1 –  Daniel Lichtblau Feb 7 at 22:53
@DanielLichtblau - I'd like to understand that but the syntax is a bit off (unbalanced parentheses and PolyReduce wants three args). Can you correct it?.. –  george2079 Feb 7 at 23:41
note the subject says "up to" while the question says "combined degree 4" .. which do you want? –  george2079 Feb 7 at 23:50
@george2079 If you remove the lparen and don't worry too much about the missing 3rd argument it should work out better. –  Daniel Lichtblau Feb 8 at 0:08
Ok.. for those who cant stand the front end sticking a red mark in their code the third arg should be a t .. –  george2079 Feb 10 at 17:25

p = Total@Flatten@Table[ a[i, j] x^i  y^j , {i, 0,5}, {j, 0, 5}]


   Total@Flatten@
MapIndexed[
If[Total@#2 - 2  == 4  , x^(#2[[1]] - 1) y^(#2[[2]] - 1)   #1,  0]&,
CoefficientList[p, {x, y}], {2}]


y^4 a[0, 4] + x y^3 a[1, 3] + x^2 y^2 a[2, 2] + x^3 y a[3, 1] + x^4 a[4, 0]

Obviously put <=4 in there to keep the lower terms..

-