Conditional expectation of a function of two random variables.

I have that (X, Y) are uniformly distributed in the triangle defined by the vertices $$(0, 0)$$, $$(1, 0)$$, and $$(0, 1)$$. I am trying to find the following expectation value:

$$E\left( (X-Y)^2 | X \right)$$

I am able to get the joint density, marginal densities, and conditional densities fairly easily. However, I am a little confused on how to go about solving this?

• As an alternative, use the second approach from here. If $(X, Y) = (U, (1 - U)V)$, then $$f_{U, V}(u, v) = 2 (1 - u) [0 < u < 1 \land 0 < v < 1], \\ \mathbb E(Y^p \mid X) = (1 - U)^p \hspace {1.5px} \mathbb E(V^p) = \frac {(1 - X)^p} {p + 1}.$$ – Maxim Apr 17 at 0:16

$$\mathbb E\left( (X-Y)^2 | X \right)= \mathbb E\left( X^2+Y^2 -2XY | X \right)=X^2+E(Y^2|X)-2XE(Y|X)$$
Since $$E(Yf(X)|X)=f(X)E(Y|X)$$ Basic_properties.
• For $E(Y|X)$, since $0 \leq y \leq 1 - x$, does the integrating remain $\int_{0}^{1-x}{y^2 f_{Y|X}(y|x) dy}$? Or must the bounds be changed? I know that if we let $Z$ be a random variable such that $Z = Y^2$, then the integration would be over $0 \leq Z \leq (1-x)^2$ but the density would be different. Would you be able to clarify this? – Eoin S Apr 15 at 23:18
• $E(Y^k|X=x)=\int_0^{1-x} y^k f(y|x) dy$. You should consider that $f(y|x)$ calculated by $f(x,y)$ so $y<1-x$. – Masoud Apr 16 at 0:56