What is the limit $\lim\limits_{(x,y)\to(1,1),\ (x,y)\in S}(1-x^py^q)(1-x^ry^s)\sum_{p/q\le m/n\le r/s}x^my^n$? Let $S=[0,1)^2$ and $m,n$ are positive integers and $p/q,r/s$ are positive rationals with $p/q<r/s$. What is the limit
$$\lim\limits_{(x,y)\to(1,1),\ (x,y)\in S}(1-x^py^q)(1-x^ry^s)\sum_{p/q\le m/n\le r/s}x^my^n?$$
The answer is $qr-ps$. Interesting this is the determinant of matrix $\begin{pmatrix} r & s \\ p & q \end{pmatrix}$. The sum $\sum_{p/q\le m/n\le r/s}x^my^n$ also seems to be of the form 
$-1+(1+(x^ry^s)+(x^ry^s)^2+\cdots)(1+(x^py^q)+(x^py^q)^2+\cdots)P(x,y),$ 
where $P(x,y)$ is a polynomial with $qr-ps$ terms, and each term $x^ay^b$ correspond to the lattice point $(a,b)$ inside the paralleogram spanned by $(p,q)$ and $(r,s)$. In other words, $(a,b)=u(p,q)+v(r,s)$ where $0\le u,v<1$, $u,v\in\mathbb{Q}$. But I don't know how to prove the number of lattice points is the determinant.
 A: First the surface of a parallelogram generated by two vectors $(p,q)$ and $(r,s)$ is (eventually up to a minus sign) equal to the determinant
$$\det\begin{pmatrix}
p&r\\
q&s
\end{pmatrix}=ps-qr\,.$$
Now let us count the number of lattice point in this parallelogram and see that it is equal to the surface of the parallelogram.
Then I would like to precise how we count the points of the lattice:


*

*If a lattice point is in the interior of the parallelogram, count it with a "weight" one.

*If it is on the boundary of the parallelogram, but not a vertex, count it with a "weight" one half.

*If it is a vertex of the parallelogram count it with a "weight" one fourth.

*If a lattice point is outside of the parallelogram, count it with "weight" zero.


Since a complete formal proof would be a bit boring and not that enlightening let's understand the principle on a picture.

Let's look at a lattice point $(m,n)$ which is in the parallelogram, and consider the square with vertices $(m,n)$, $(m+1,n)$, $(m+1,n+1)$,$(m,n+1)$.


*

*Case 0: The square is fully in th parallelogram and then it contributes to one unit of the total area of the parallelogram.

*Case 1: A part of the the square is outside of the parallelogram but by translating by the vector $\pm(p,q)$ one arrives to a square whose area complete exacly the one of the original square. See the squares 1 and 1' on the picture. A similar case can occur with $\pm(r,s)$ instead of $\pm(p,q)$.

*Case 2: A part of the square is outside of the parallelogram, but by translating by $(p,q)$ or $(r,s)$ one obtain two squares which complete the original one, and the lattices point at the lower left corner count for one in the count for one. This would be the case of the square 2, 2', 2'', or 3, 3' and 3''.


Remark 1: In fact the square 2 corresponds to four squares, but I did not represent the fourth one with lower-left corner $(p+r,q+s)$ as it would have contributed to zero in the area. But it is important when one counts the corresponding points in the lattice.
Remark 2: I slightly cheated: Other cases can occur when the parallelogram is very flat, but one can adapt the method, but with more translations.
