Find the minimum value of $f=x^2+y^2+x(1-y)+y(1-x)$, holds on $x,y$ are integers. Let $x$ and $y$ are integers such that $-2\le x\le3$ and $-8\le y\le4$
Find the minimum value of $f=x^2+y^2+x(1-y)+y(1-x)\tag{1}$
From $(1)$, I get $f=(x-y)^2+x+y$ and I don't know what I should do next.
I had tried to use differential of f then I get no critical point (the minimum is on the bound $x=-2,x=3,y=-8$ or $y=4$). I found the minimum on $x=-2$ but $y=-2.5$ that isn't integer, the equation f that holds on $x=-2$ is $(y+2.5)^2-4.25,$ So no conclusion for $x,y$ are integers or Can it conclude that $y=2,3$ minimize f ? (I think this solution is suitable for real numbers).
I had tried to substitute all the possible cases then I got the minimum is $-4$, when $(x,y)$=$(-2,-2)$, $(-2,-3)$.  
All help would be appreciated.
 A: Because $x$ and $y$ are integers, we have $$f(x,y)=(y-x)^2+(y-x)+2x=\left(y-x+\frac{1}{2}\right)^2+2x-\frac{1}{4}\geq \frac{1}{4}+2x-\frac{1}{4}=2x\geq-4\,.$$
Therefore, $f(x,y)\geq-4$.  The equality holds iff $y-x+\frac{1}{2}=\pm\frac{1}{2}$ and $x=-2$, which leads to $(x,y)=(-2,-2)$ and $(x,y)=(-2,-3)$.
If $x$ and $y$ may take non-integral values (within the required ranges), then
$$f(x,y)\geq 2x-\frac{1}{4}\geq -\frac{17}{4}\,.$$
The equality holds iff $y-x+\frac{1}{2}=0$ and $x=-2$, i.e., $(x,y)=\left(-2,-\frac{5}{2}\right)$.
For the maximum, we note that $-\frac{21}{2}\leq y-x+\frac{1}{2}\leq \frac{13}{2}$, so $$f(x,y)\leq \frac{441}{4}+2x-\frac{1}{4}= 110+2x\leq 116\,.$$
The equality holds if and only if $y-x+\frac{1}{2}=-\frac{21}{2}$ and $x=3$, which means $(x,y)=(3,-8)$.
A: This is a kind of solving :
you can write a program in matlab to find minimum 
a=zeros(6,13);  
for x=-2:3 
for y=-8:4  


    a(x+3,y+9)=(x-y)^2+x+y
end; 

end;
if you run this ,you will have 
$f(x,y)=(x-y)^2+x+y$

as you can see max $f(x,y)=116 $ ,min $f(x,y)=-4$
A: Brute-forcing in Haskell:
Prelude> let f x y = x**2 + y**2 + x*(1-y) + y*(1-x)
Prelude> let graph = [ ((x,y),f x y) | x <- [-2..3], y <- [-8..4] ]
Prelude> minimum (map snd graph)
-4.0
Prelude> filter (\((x,y),z)->(z==(-4.0))) graph
[((-2.0,-3.0),-4.0),((-2.0,-2.0),-4.0)]

Thus, the minimum is $-4$ and the minimizers are indeed $(-2,-3)$ and $(-2,-2)$.
