Probability : find $P(|X-y|<1/2)$ for a uniform distribution of $x,y$ The question : 
Two guys pick a random point between $[0,2]$ (uniform distribution)      . find the probability that the distance between the points is < $0.5$
$$X - \text{first point} $$
$$Y - \text{second point}$$
so because they are random $$f(x,y)=f(x)*f(y)=0.25$$
So I wrote $$P(|X-Y|<0.5) = P(-0.5<x-y<0.5)= P(x-y<0.5)-p(x-y<-0.5)
=P(x<y+0.5)-p(x<y-0.5)$$
using the integrals 
$$\int_0^2 \int_0^{y+0.5} 0.25 dxdy-\int_0^2 \int_0^{y-0.5}0.25 dxdy $$
I get $0.5$ and the answer is $7/16$ according to my professor.
What am I'm doing wrong ? I can draw the graph and see the limits but I think it's faster like that.
Thanks
 A: Well your domain of integration is wrong. For example, $y+0.5$ goes beyond $2$. 

It is always advisable to sketch a diagram.
A quick way to solve this question is simply calculate the corresponding area multiplied by the density.
$$\frac14 \left( 4 - 2 \times \frac12 \left( \frac32 \right)^2 \right) =1-\frac{9}{16}=\frac7{16}$$
Edit: 
\begin{align}
&\int_0^2 \int_0^{y+0.5} f(x,y) \,dx \, dy - \int_0^2 \int_0^{y-0.5}f(x,y) \,dx \, dy \\
&=\int_0^2 \int_0^{y+0.5} \frac14 \mathbb{1}_{0 \leq x \leq 2, 0 \leq y \leq 2 } \,dx \, dy - \int_0^2 \int_0^{y-0.5}\frac14 \mathbb{1}_{0 \leq x \leq 2, 0 \leq y \leq 2 }  \,dx \, dy \\
\\&=\int_0^2 \int_0^{\min(2,y+0.5)}  \frac14\,dx \, dy-\int_{\frac12}^2 \int_0^{y-0.5} \frac14 \,dx\,dy
\end{align}
A: You're wrong on your use of the probability formula. Your double inequality stands for intersection of two sets!
Define $A=\lvert −0.5<x−y\lvert$, $B=\lvert x−y<0.5\lvert$, now 
$P(AB)=P(A)+P(B)-P(AUB)$ and you can do the rest!
A: I confirmed your professor's answer. Just write
$$P(|X-Y|<\tfrac12) =\int_{-\infty}^{\infty}P(|X-y|<\tfrac12|Y=y)f_Y(y)\;dy$$
$$= \int_{-\infty}^{\infty}P(-\tfrac12<X-y<\tfrac12|Y=y)f_Y(y)\;dy$$
$$= \int_{-\infty}^{\infty}P(y-\tfrac12<X<y+\tfrac12|Y=y)f_Y(y)\;dy$$
$$= \int_{-\infty}^{\infty}[F_X(y+\tfrac12)-F_X(y-\tfrac12)]f_Y(y)\;dy\tag{$*$}$$
You know that the PDF for $X$ is
$$f_X(x)=\begin{cases}0,&x\leq 0\\
\tfrac12,&0<x<2\\
0,&x\geq 2\end{cases}$$
and the CDF for $X$ is therefore
$$F_X(x)=\begin{cases}0,&x\leq 0\\
\tfrac x2,&0<x<2\\1,&x\geq 2\end{cases}$$
(and identically so for Y as well).
Now just plug in and compute the integral $(*)$.
