TITLE: Area-differences for lattice triangles in a checkerboard
QUESTION [27 upvotes]: For positive integers $m$ and $n$, what is the integral of the function $(-1)^{\lfloor x \rfloor + \lfloor y \rfloor}$ on the triangle with vertices $(0,0)$, $(m,0)$, and $(0,n)$?
Pictorially, we are putting a red/black checkerboard coloring on the plane and finding the signed difference between the red region enclosed by the triangle and the black region enclosed by the triangle.
Call this integral $I(m,n)$. Here are some values of $I(m,n)$ (if my calculations of signed sums of areas of little triangles and trapezoids are correct):
$\begin{array}{c|ccccc} & 1 & 2 & 3 & 4 & 5 \\ 
\hline 
1 & 1/2 & 1/2 & 1/2 & 1/2 & 1/2 \\
2 & 1/2 & 0 & -1/6 & 0 & 1/10 \\
3 & 1/2 & -1/6 & 1/2 & 5/6 & 1/2 \\
4 & 1/2 & 0 & 5/6 & 0 & -1/2 \\
5 & 1/2 & 1/10 & 1/2 & -1/2 & 1/2
\end{array}$
It would be good to tabulate more values. Can any computer algebra systems handle such computations for specific $m,n$?
Obviously $I(m,n) = I(n,m)$, and an easy telescoping-sum argument shows that $I(1,n)=1/2$. A symmetry argument shows that $I(m,n)=1/2$ when $m$ and $n$ are both odd, and from this it can be proved that $I(m,n)=0$ when $m$ and $n$ are both even. The values of $I(m,n)$ where $m$ and $n$ have opposite parity seem more subtle.

REPLY [2 votes]: Some people have noticed that $mnI(m,n)$ is an integer when $m, n$ opposite parity. It is actually proved in jcdornano's reply with a nice argument I think. As it might not be very clearly expressed, I took the liberty to rewrite it here.
Let $m$ be even number and let $T$ be the triangle of vertices $(0,0)$, $(m,0)$, and $(0,n)$ with a black and white coloring $C$ as  explained in the initial post.
Let us consider $L$ the linear application that multiplies the absiceas by $n$ and the ordinates by $m$ and let us consider $T' $ the image of $T$ by $L$. $L$ naturally induces a coloring $C'$ on $T'$: the images of the black subset of $T$ is a black subset of $T'$ and the images of the white subset of $T$ is a white subset of $T'$.
Language convention: Let $X$ be any black and white coloring of the plane. we can associates to $X$ a function $f $ whose value is $1$ on the white parts and $-1$ on the black parts. By abuse, we will speak of the integral of $X$ to mean the itegral of $f$.
Let $I' $ be the integral of $C'$ on $T'$. It is immediate that $I(n,m)=I'/mn$.
To prove that $I(n,m).nm$ is an integer, we just have to prove that $ I' $ is an integer.
Let us prove this fact. Since $T'$ is isocele, the points of its hypothenus with integer ordinate also have an integer absicea. Let us denote these points by $A_0, A_1, A_2, ..., A_{nm}$.
For any $0\leq i\leq nm-1$, let $T_i$ be the right triangle whose hypothenuse is $[A_i A_{i+1}]$.
$T'$ is the union of :

$\cup_{i=1}^{nm} T_i$
$S = T'\setminus \cup_{i=1}^{nm}T_i$.

Let $I_1$ be the integal of $C'$ on $S$ and let $I_2$ be the integal of $C'$ on $ \cup_{i=1}^{nm} T_i$.  $I' = I_1+I_2$. Let us prove that $I_1=0 $ et that $ I_2$ is an integer.
Because the points $A_i$ have integers coordinates, $S$ is the union of squares of the form $[j,j+1]*[k,k+1]$ where $j,k\in \mathbb N$. Since such squares are either entirerly white or entirerly black, the value of the integral of $C'$ on them is $1 $ or $-1$ and the integral of C' on S in an integer.
Let us now prove that $I_2 $ is equal to $0$. Because $T' $ is an isocele triangle , all the triangles $T_i $ are isometrics one to the other. There are an even number of them with half of them being black while the other half being white. Hence they "compensate" each other and $I_2=0$.