<s>[INST] Trouble with a Probability (Integral) Computation from *All of Statistics* From All of Statistics pg. 36:

Suppose that $X$ and $Y$ are independent and both have the same density $f(x) = 2x$ for $0 \le x \le 1$ and $f(x) = 0$ otherwise. Let us find $\mathbb{P}(X + Y \le 1)$. Using independence, the joint density is 
$$
f(x,y) = f_X(x) f_Y(y) = 4xy \text { if } 0 \le x \le 1, 0 \le y \le 1
$$
Now
\begin{equation}
\begin{split}
\mathbb{P}(X + Y \le 1) & = \int \int_{x+y \le 1} f(x,y) dy dx \\
                        & = 4 \int_0^1 x \left[ \int_0^{1-x} y dy \right] dx \\
                        & = 4 \int_0^1 x \frac{(1-x)^2}{2} dx \\
                        & = \frac{1}{6}
\end{split}
\end{equation}

Question 1: Why are we integrating on $\int_0^1$ for the outside integral and on $\int_0^{1-x}$ on the inside integral?
Question 2: According to the last step, it must be that $\int_0^1 x \frac{(1-x)^2}{2} dx = 1/24$. But why is this the case? How is this integral computed?
 [/INST] Question 1: The integral is over the region $x+y \leq 1$. You are also constrained to $0 \leq x \leq 1$ and $0 \leq y \leq 1$ because of the densities of $X$ and $Y$. If you draw the $1 \times 1$ box where $0  \leq x \leq 1$ and $0 \leq y \leq 1$, then draw the line $x+y=1$ and shade the part below the line where $x+y \leq 1$ (equivalently, $y \leq 1-x$), you will see the triangular region over which you are integrating. Since the order of integration is $dydx$, you must find constant limits for the $x$ variable, which can range between $0$ and $1$. Then you must find limits for $y$ in terms of $x$. For every $x$ value, $y$ is bounded below by $0$ and above by $1-x$, since $y \leq 1-x$. 
Question 2: 
\begin{align*}
\int_0^1 x\frac{(1-x)^2}{2}dx &= \frac{1}{2}\int_0^1 x(1-2x+x^2)dx\\
&=\frac{1}{2}\int_0^1 (x-2x^2+x^3)dx\\
&=\frac{1}{2}\left(\frac{x^2}{2}-\frac{2}{3}x^3+\frac{1}{4}x^3\right)\Bigg|_0^1\\
&=\frac{1}{2}\left(\frac{1}{2}-\frac{2}{3}+\frac{1}{4}\right)\\
&=\frac{1}{2}\left(\frac{6}{12}-\frac{8}{12}+\frac{3}{12}\right)\\
&=\frac{1}{2}\cdot \frac{1}{12}\\
&=\frac{1}{24}.
\end{align*}
</s>