# Convolution of the PDFs of $2$ Independent Random Variables

I'm having trouble getting the correct pdf for $Z$ in the problem $Z = X + Y$ where the pdf of $X$ and $Y$ are

f_x(x) = f_y(x) = \left\{\begin{aligned} &x/2 &&: 0 < x < 2\\ &0 &&: \text{otherwise} \end{aligned} \right.

I am solving this using the convolution

$$f_z(w) = \int_{-\infty}^\infty f_x(x)f_y(w-x) \, dx.$$

The limits can be changed to $0$ and $2$ in order for $f_x(x)$ to have a non-zero value and then $f_x(x)$ will equal $x/2$.

$$f_z(w) = \frac{1}{2}\int_{0}^2 xf_y(w-x) \, dx$$

In order for $fy(w-x)$ to have a non-zero value, $0 < w-x < 2 \implies x < w < 2 + x$. After drawing a picture, I found two cases that can be tested, these being:

$$\text{Case 1}: 0 \le w \le 2$$

$$\text{Case 2}: 2 \le w \le 4$$

For case $1$, the bounds are $0$ and $w$, giving

$$f_z(w) = \frac{1}{2}\int_{0}^w x f_y(w-x) \, dx = \frac{1}{4}\int_{0}^w x^2 \, dx = w^3 /12.$$

For case $2$, the bounds are $w-2$ and $2$ giving

$$f_z(w) = \frac{1}{2}\int_{w-2}^2 xf_y(w-x) \, dx = \frac{1}{4}\int_{w-2}^2 x^2 \, dx = (8-(w-2)^3) /12$$

Combining the two cases, we get

f_z(w) = \left\{\begin{aligned} &w^3 /12 &&: 0 \le w \le 2\\ &(8-(w-2)^3) /12 &&: 2 < w \le 4\\ &0 &&: \text{otherwise} \end{aligned} \right.

This can't be right because the area under $f_z(w) = 4/3$, not $1$. Can I get some advice on where I went wrong with this calculation?

You computed the limits of integration correctly. But you substituted wrong expressions for $f_y(w-x)$ in both integrals. In particular, $$f_y(w-x) = (w-x)/2$$ when $0<(w-x)<2$. Therefore, your integrals would be $$f_z(w) = \frac{1}{4}\int_{0}^{w}x(w-x)\,dx$$ for $0 \le w \le 2$ and $$f_z(w) = \frac{1}{4}\int_{w-2}^{2}x(w-x)\,dx$$ for $2 \le w \le 4$.