The idea here is to use convolution. The books does the following:
Let $z=X+Y$. I have that $$f_Z(x)=\int_{-\infty}^{\infty}f_Y(x-u)f_X(u) \ du.\tag 1$$
First we note that the range of $Z$ is $[0,2],$ so we need to pick our $x$ from that interval. Now $f_X(u)=1$ if $u$ is between $0$ and $1$ and $0$ otherwise. For the other factor in the integrand, note that $f_Y(x-u)=1$ if its argument $x-u$ is between $0$ and $1$, that is $\color{green}{0\le x-u \le 1}$, and $0$ otherwise. Since $x$ is fixed and $u$ is the variable, we rewrite this as $\color{red}{x-1\le u \le 1}.$ Hence for any $x\in[0,2]$ the two inequalities
$$0\le u\le 1 \quad \text{and} \quad \color{brown}{x-1\le u\le x}\tag 2$$
must be satisfied and if they are, the integrand equals $1$. We need to distinguish between 2 cases:
Case 1: $x\in[0,1].$ In this case, the two conditions in $(2)$ are satisfied if $0\le u \le x.$ Hence, for $0\le x \le 1$
$$f_Z(x)=\int_0^xdu=x, \quad 0\le x\le 1.$$
Case 2: $x\in[1,2]$. Here, the conditions are satisfied if $x-1\le u \le 1$, ad we get
$$f_Z(x)=\int_{x-1}^1du=2-x, \quad 1\le x \le 2.$$
Questions:
- I don't understand how they go from the green, to red to brown inequality. Is there a typo in the book?
- I still don't understand the need to split this into two cases and how they came up with the bounds.
The inequalities come from simple equivalent transformations. E.g., $x-u\leq 1$, add $u-1$ to both sides, and then you obtain $x-1\leq u$.
You need to split into two cases because the relevant interval, where $f$ is nonzero, is $[0,1]$. The value of $f(x-u)$ and $f(u)$ depend on whether or not $x-u$ or $u$ is in or out of the interval $[0,1]$.