Counting integer solutions for a system of (in)equalities

512 Views Asked by At

I wish to enumerate the number of solutions of the system of equations and inequalities for 3 non-negative integer unknowns $x,y,z \ge 0$: ($a$,$b$ specified) \begin{align} x+y+z&=a\\ x+y&>b\\ y+z&>b \end{align}

Is there an elegant way of finding the number of solutions or must I use an exhaustive numerical algorithm. Actually, further on I'll have more complicated systems of this type with more unknowns and more inequalities.

2

There are 2 best solutions below

1
On

You are counting the lattice point in a triangle, and the magic words are Pick's Theorem In higher dimensions, the question is higher, see the answer to this: https://mathoverflow.net/questions/10266/counting-lattice-points-on-an-n-simplex

1
On

We may suppose that $b\in \{-1,0,1,\dots,a-1\}.$

We consider the plane $(x,z)$, your bounds are $x+z\leqslant a$, $0\leqslant x,z<a-b$. Now fix $x$, then $z$ varies from 0 to $\min(a-x,a-b-1)$. So, for $x\leqslant b$ there are $a-b$ ways to choose $z$, and for $a\geqslant x\geqslant b+1$ there exist $a-x+1$ ways to choose $z$. Totally we get $(b+1)(a-b)+(a-b)(a-b+1)/2=(a-b)(a+b+3)/2$ solutions.