# Compute a marginal density function from a joint density function

I am in the middle of an exercice dealing with this joint density function :

$$f_{x,y}(x,y) = \frac{x^2+y}{a}$$ for $$0 < x < y < 2$$

I have been asked to compute the marginal densities and I know how to do it but I am struggling with the bounds. To verify that this joint density function is legit, I found the value of a using this boundaries :

$$\int_{0}^{2}\int_{x}^{2} \frac{x^2+y}{a} \,dydx$$

This bounds makes perfect sense and I found $$a = 4$$

My problem is when it comes to the marginal

I started like this using the same bounds for x : $$\int_{x}^{2} \frac{x^2+y}{4} \,dy$$

Then, I was about to do this :

$$\int_{0}^{2} \frac{x^2+y}{4} \,dx$$

But the solutions say that we have to do it on the interval from 0 to y.

Could you explain me why ?

For a given value of $$Y$$, by definition, the joint distribution is non-zero in the region $$0. So, when you fix $$Y$$ and sum over all values of $$X$$, it must go until $$Y$$ and not until $$X$$.
Another idea: symmetry. If you understand why in the marginal of $$X$$ the limits of the integral are $$x$$ to $$2$$, then the same argument should apply for the marginal of $$Y$$. Remember that the double integral you did in the beginning only goes over the entire region the marginal distributions go over only over lines in which one of the variables is fixed.