Calculating conditional variance using two different methods 
The stock prices of two companies at the end of any given year are modeled with random variables $X$ and $Y$ that follow a distribution with joint density function $f(x, y) = 2x$ for $0<x<1, x<y<x+1$ and $0$ otherwise. What is the conditional variance of $Y$ given $X=x$?

My attempt:
$$Var[Y|X=x] = E[Y^2|X=x] - (E[Y|X=x])^2$$
Now, $E[Y^2|X=x] = \int_0^2y^2\cdot f(y|X=x) \; dy$. Note that $f(y|X=x) = \dfrac{f(x,y)}{f_X(x)} = \dfrac{2x}{\int_x^{x+1}2x \; dy} = 1$. So, $E[Y^2|X=x] = \int_0^2y^2 \; dy = \dfrac{8}{3}$.
Next, $E[Y|X=x] = \int_0^2y\cdot f(y|X=x) \; dy = \int_0^2y\; dy = 2$.
So, $Var[Y|X=x] = \dfrac{8}{3} - 4 = \dfrac{-4}{3}$
which is not the correct answer. Where have I gone wrong?
Alternatively, when I recognize that $f(y|X=x) = 1 \implies W \sim Unif[0, 2]$ where $W = Y|X=x$, I can use the formula for the variance of a uniform distribution to calculate the conditional variance as follows:
$$Var[W] = \frac{(2-0)^2}{12} = \frac{1}{3}$$
which is not the correct answer either. Where have I gone wrong with this approach? Thanks!

The main mistake is that the conditional density is actually $$f(y \mid X=x) = \begin{cases} 1 & x < y < x+1 \\ 0 & \text{otherwise}\end{cases}$$
It is very important to consider the support of the density.

In the first approach, you have
$$E[Y \mid X=x] = \int_x^{x+1} y \, dy = \frac{(x+1)^2 - x^2}{2} = x + \frac{1}{2}$$
and
$$E[Y^2 \mid X=x] = \int_x^{x+1} y^2 \, dy = \frac{(x+1)^3 - x^3}{3} = x^2 + x + \frac{1}{3}.$$
So the variance is
$$x^2 + x + \frac{1}{3} - (x+1/2)^2 = \frac{1}{3} - \frac{1}{4} = \frac{1}{12}.$$

In the second approach, you have $W \sim \text{Unif}[x, x+1]$, so the conditional variance is $\frac{((x+1)-x)^2}{12} = \frac{1}{12}$.
