I am trying to solve the following problem
Find the coefficient of $x^{31}$ in the expansion of $(x^4+x^2-\tfrac{x}{12}-\tfrac{1}{3x})^9$.
By using multinomial expansion below,
$$ (x^4+x^2-\tfrac{x}{12}-\tfrac{1}{3x})^9 =\sum_{a+b+c+d=9} {9 \choose {a,b,c,d}}(x^4)^a (x^2)^b \left(-\frac{x}{12}\right)^c \left(-\frac{1}{3x}\right)^d $$
and with some algebraic manipulation, I need to find all non-negative tuples $(a,b,c,d)$ with a constraint of $a+b+c+d=9$ and $4a+2b+c-d=31$.
With Mathematica, I did the following.
ClearAll[data]
data = Flatten[Permutations /@ IntegerPartitions[9, {4}, Range[0, 9]], 1];
Select[data, 4 #[[1]] + 2 #[[2]] + #[[3]] - #[[4]] == 31 &]
The solution is $\left( \begin{array}{cccc} 8 & 0 & 0 & 1 \\ 7 & 1 & 1 & 0 \\ \end{array} \right)$.
Question
What is the strategy to find the tuples easily?
By adding the equations, you get $c=20-(5/2)a-(3/2)b$ and by subtracting them, you get $d=(3/2)a+(1/2)b-11$.
Plot the lines $c=0$ and $d=0$ on the $(a,b)$ plane. They, along with the $a$-axis and $b$-axis, bound the region where all four are nonnegative.
Select gridpoints within the region where $a$ and $b$ are eithwr both even or both odd.