Suppose that random variables $Y_1$ and $Y_2$ have a joint probability density function $$f(y_1,y_2)=6y_1^2y_2$$ with $0 \leq y_1 \leq y_2,y_1 + y_2 \leq2$.
I am trying to find the marginal density function of $Y_2$. So far, I have $$ f_{Y_2}(y_2)=\int_{0}^{y_2}f(y_1, y_2)dy_1=\int_{0}^{y_2}6y_1^2y_2dy_1=2y_2^4 $$ with $0\leq y_2\leq 1$
But the integral of $f_{Y_2}(y_2)$ from $0$ to $1$ is not one. I believe I did something wrong.
Thanks to @angryavian \begin{align*} f_{Y_2}(y_2)&=\int_{0}^{\min\{y_2,2-y_2\}}f(y_1, y_2)dy_1\\ &= \begin{cases} \int_{0}^{y_2}6y_1^2y_2dy_1&\hspace{5mm}0\leq y_2\leq 1\\ \int_{0}^{2-y_2}6y_1^2y_2dy_1&\hspace{5mm}1\leq y_2\leq 2 \end{cases}\\ &= \begin{cases} 2y_2^4&\hspace{5mm}0\leq y_2\leq 1\\ -2(y_2-2)^3y_2&\hspace{5mm}1\leq y_2\leq 2 \end{cases} \end{align*}
the integral is one $$\int_{0}^{1}2y_2^4dy_2+\int_{1}^{2}-2(y_2-2)^3y_2dy_2=1$$