I have a polynomial like this:
ser = 1 - x/2 - x^2/8 - x^3/16 + y/2 + (3 x y)/4 + (23 x^2 y)/16 + ( 27 x^3 y)/32 - y^2/8 - (31 x y^2)/16 - (127 x^2 y^2)/64 - ( 351 x^3 y^2)/128 + y^3/16 + (35 x y^3)/32 + (407 x^2 y^3)/128 + ( 1915 x^3 y^3)/256;
Now I want to extract the terms with total degree smaller than 4. Using patterns, I can realize the goal.
Cases[ser, (_*x^m_.*y^n_. /; m + n < 5) | (_?NumericQ*y^j_. /; j < 5) | (_?NumericQ*x^i_. /; i < 5) | _?NumericQ]
But I think my method is a little tedious. I have two questions: 1. can my method be simplified? 2. are there other simple methods to do the job?