Finding marginal density from a joint density when range of random variables are dependent on one another. I have two joint density problems, where I would like to find the marginal density.
The first one: $f(x,y) = 24xy, 0 \leq x \leq 1, 0 \leq y \leq 1, 0 \leq x+y \leq 1$
So, I "integrate out y" and get $f_x(x)=\int_{-\infty}^{\infty} 24xydy =12x $
I don't feel like this is right because I no longer have an handle on the extra condition of $x+y\leq1$, and if I integrate $12x$ over $[0,1]$, I just would get 6, instead of 1.
The second one: $\frac{1}{8}(y^2-x^2)e^{-y} -y \leq x \leq y, 0 < y < \infty$
Again, integrating out the y here seems to be the wrong approach because I'm not taking into consideration the relationship between x and y.
How would I proceed then in these two cases to find the marginal densities?
Thanks!

$$f(x,y)=24xy$$
First integrate with respect to $y$, because $x+y \leq 1$ then $y$ goes from $0$ to $1-x$
$$\int_0^{1-x} 24xy dy=12x(1-x)^2$$
Second to check it's every okay we integrate with respect to $x$:
$$\int_0^1 12x(1-x)^2dx=1$$
As you thought when you are integrating you can take the variable out just when you have independence which if I'm not a mistake only happen when you have a squared domain. 
