Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

I want to count the number of non-negative integer solutions to an equation such as


I can do this using generating functions; for example, the answer here is

$$[x^n]\frac{1}{(1-x)(1-x^5)(1-x^8)}$$ where $[x^n]$ is the coefficient of $x^n$.

But what if I add a restriction between variables such as $y \le z$? I have no idea how to count the number of solutions with this additional constraint. Any suggestions?

share|cite|improve this question
up vote 14 down vote accepted

If you want $y\leq z$, use the substitution $z = y + z'$, and you're solving $x + 5y + 8(y+z') = n$, which is equivalent to non-negative integer solutions for $x + 13y + 8 z' = n$.

If you want $x\leq y \leq z$, a similar method will work. You could also do this for $2y \leq z$.

Of course, with more restrictions, this can get harder to clearly do. It could be difficult to solve subject to $x \leq y, z \leq 2y, x \geq \pi z$ (assuming any solutions exist).

share|cite|improve this answer
Perfect, just what I was looking for. – user79913 May 28 '13 at 20:17

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.