# Obtaining probability density function $f_Y(y)$ when we know joint probability distribution $f(x,y) = 1/(x+1)$

Suppose joint probability density function is $f(x,y) = 1/(x+1)$ for $0<x<1$ and $0<y<x+1$. I try to calculate marginal density function $f_Y(y)$ by $$f_Y(y) = \int_{y-1}^1 \frac{1}{x+1}dx = \ln(2)-\ln(y)$$ But this does not seem to be a right answer. Where did I go wrong?

We need to draw a picture. Draw the line $y=x+1$. If we look at the conditions, we can see that the joint density lives on the trapezoid bounded by the $y$-axis, the $x$-axis, the vertical line $x=1$, and the line $y=x+1$.

We want to "integrate out" $x$. Look at the picture. If $0\le y\le 1$, then $x$ travels freely from $0$ to $1$, and hence the density function of $y$ is $$\int_0^1 \frac{1}{x+1}\,dx.$$ This is $\ln 2$.

If $1\lt y\le 2$, then, as in your solution, $x$ starts on the line $y=x+1$ and travels to $1$, so $x$ goes from $y-1$ to $1$, and hence there the density function is $$\int_{y-1}^1\frac{1}{x+1}\,dx,$$ which is $\ln 2-\ln y$.

We conclude that the marginal density of $Y$ is $\ln 2$ in the interval $[0,1]$, and $\ln 2-\ln y$ in the interval $(1,2]$, and $0$ elsewhere.

Without the picture, the appropriate bounds for the integral, for various values of $y$, would not have been clear.

When $y \in [0,1]$ you need integrate over x in $[0,1]$, when $y>1$ you have integrate over x in $[y-1,1]$