<s>[INST] Distribution of $Z=\left\{\begin{matrix} X+Y & \operatorname{if} & X+Y<1\\ X+Y-1 & \operatorname{if} & X+Y>1 \end{matrix}\right.$ Let $X\perp Y$ be two random variables with uniform distribution on $[0,1]$. How is it possible that $F_Z(z)=z$?
Initially I wrote $F_Z(z)=\mathbb{P}(Z\leq z)=\mathbb{P}(X+Y\leq z,X+Y<1)+\mathbb{P}(X+Y-1\leq z,X+Y>1)$, and I started to study the first probability. For the triangle with vertices $(0,0),(0,1),(1,0)$ and longest side bounded by the line $y=1-x$, I plotted the line $y=z-x$ and I tried to study the different cases ($0<z<\frac{1}{2}$ and $\frac{1}{2}<z<1$). I thought the my approach was correct, but when I saw $F_Z(z)=z$ my entire argument was lacking. Where was I wrong? Could you please give me any hints on how solve the problem?
Thanks in advance.
 [/INST] For $z\in\left(0,1\right)$ we find:
$$\begin{aligned}P\left(Z\leq z\right) & =P\left(Z\leq z,X+Y<1\right)+P\left(Z\leq z,X+Y>1\right)\\
 & =P\left(X+Y\leq z,X+Y<1\right)+P\left(X+Y-1\leq z,X+Y>1\right)\\
 & =P\left(X+Y<z\right)+P\left(1<X+Y<1+z\right)\\
 & =\frac{1}{2}z^{2}+\left[\frac{1}{2}-\frac{1}{2}\left(1-z\right)^{2}\right]=z
\end{aligned}
$$

Addendum:
To find the two probabilities it is handsome to make a picture and to find the areas that are involved.
Integration in order to find $P(1<X+Y<1+z)$ works like this:
$$\begin{aligned}P\left(1<X+Y<1+z\right) & =\int_{0}^{z}\int_{1-x}^{1}dydx+\int_{z}^{1}\int_{1-x}^{1-x+z}dydx\\
 & =\int_{0}^{z}xdx+\int_{z}^{1}zdx\\
 & =\frac{1}{2}z^{2}+z\left(1-z\right)\\
 & =z-\frac{1}{2}z^{2}
\end{aligned}
$$
Or - making use of the fact that $1-X\stackrel{d}{=}X$ and $1-Y\stackrel{d}{=}Y$
$$\begin{aligned}P\left(1<X+Y<1+z\right) & =P\left(1<X+Y\right)-P\left(1+z<X+Y\right)\\
 & =\frac{1}{2}-P\left(1-X+1-Y<1-z\right)\\
 & =\frac{1}{2}-\frac{1}{2}\left(1-z\right)^{2}\\
 & =z-\frac{1}{2}z^{2}
\end{aligned}
$$
</s>