Given
\begin{align*} f(x, y) = \begin{cases} 2x & \text{ if } 0 < x < 1, \hspace{0.3cm} x < y < x + 1 \\ 0 & \text{ otherwise,} \end{cases} \end{align*}
(a) Find the conditional pdf $f_{Y \mid X}(y \mid x)$ of $Y$ given $X = x$.
(b) Find the conditional expectation $\mathbb{E}[Y \mid X = x]$ of $Y$ given $X = x$
(c) Find the conditional variance $\text{Var}(Y \mid X = x)$ of $Y$ given $X = x$.
My try:
(a) $$f_{Y \mid X}(y \mid x) = \frac{f(x, y)}{f_{X}(x)} = \frac{2x}{\int_{x}^{x + 1} 2x \mathop{dy}} = \frac{2x}{2x} = 1$$
for $0 < x < 1$
(b) $\mathbb{E}[Y \mid X = x]$ is computed as follows:
$$\int_{x}^{x + 1} y \mathop{dy} = \boxed{\frac{2x + 1}{2}}$$
(c) First find the second moment
$$\mathbb{E}[Y^{2} \mid X = x] = \int_{x}^{x + 1} y^{2} \mathop{dy} = \frac{(x + 1)^{3} - x^{2}}{3} = \frac{3x^2 + 3x + 1}{3}$$ Therefore,
$$ \begin{align*} \text{Var}(Y \mid X = x) = \mathbb{E}[Y^2 \mid X = x] - (\mathbb{E}[Y \mid X = x])^{2} = \frac{3x^2 + 3x + 1}{3} - \frac{4x^2 + 4x + 1}{4} \end{align*} $$
Did I solve this problem correctly?
Use indicator functions while writing density functions to keep track of the support of the distributions.
One can directly see that the joint density factors as
\begin{align} f(x,y)&=2x\,\mathbf1_{0<x<1\,,\,x<y<x+1} \\&=\underbrace{\mathbf1_{x<y<x+1}}_{f_{Y\mid X}(y)}\,\underbrace{2x\,\mathbf1_{0<x<1}}_{f_X(x)} \end{align}
This shows that $Y\mid X$ has a uniform distribution over $(x,x+1)$ for each $0<x<1$.
It follows that for each $0<x<1$, $$E\left[Y\mid X=x\right]=\frac{2x+1}{2}$$
and $$\operatorname{Var}\left[Y\mid X=x\right]=\frac{1}{12}$$