Conditional expectation of order statistics. Given that $X,Y \sim \operatorname{Unif}[0,1]$, find $E[\max(X,Y)\mid X]$
My approach was:
If $X=x$, then $E[\max(X,Y)\mid X=x] = E[\max(x,Y)\mid X=x] = E[\max(x,Y)] = E[Z]$. After that i found the c.d.f. of Z, $$F_z (z) = P(Y\le x)\cdot I(0 < z \le x) + P(Y\le z)\cdot I(x \le z \le 1) + I(z\ge 1).$$ Then, given that $Z$ is non-negative : $$E[Z]= \int_0^x (1-x)\,dz + \int_x^1 (1-z)\,dz = \frac{1-x^2} 2.$$ Then $$E[\max(X,Y)\mid X] = \frac{1-X^2} 2$$ But this result doesn't satisfy the conditional that $E[E[X\mid Y]]=E[X]$, there is something wrong in my work?
 A: It should satisfy $\mathsf E(\max\{X,Y\})=\mathsf E(\mathsf E(\max\{X,Y\}\mid X))$, so yes, there is something wrong with your work.
Since $X,Y$ are iid uniform $(0;1)$, it is simply:
$$\mathsf E(\max\{X,Y\}\mid X) ~{=  \int_0^X X~\mathrm d y+\int_X^1 y~\mathrm d y \\= \dfrac{X^2+1}{2}}$$
That is all.

PS: for $x\in(0;1)$ we have $F_{\max\{x,Y\}}(z) ~{= 0\cdot I(z<x)+F_Y(z)\cdot I(x\leq z<1)+I(1\leq z)\\ = x\cdot I(z=x)+z\cdot I(x< z\leq 1)+I(1< z)}\\ \mathsf E(Z) ~{= x F_Z(x)+\int_0^1 (1-z)\mathrm d z \\ = \frac{x^2+1}{2}}$
It is the massive point at $Z=x$ that is throwing you off the cliff.
A: Suppose $0\le z\le 1.$ Then
\begin{align}
F_Z(z) = F_{\max\{\,x,\, Y\,\}} (z) = \Pr(\max\{x,Y\}\le z) &  = \begin{cases} 0 & \text{if } z<x, \\
\Pr(Y\le z) & \text{otherwise.} \end{cases} \\[12pt]
& = \begin{cases} 0 & \text{if } z<x, \\ z & \text{if } z\ge x. \end{cases}
\end{align}
Therefore $\Pr(Z=x) = x$ and, since $F'_Z(z) = 1$ for $x<z<1,$ we have
$$
\operatorname{E}(Z) = x\Pr(Z=x) + \int_x^1 z \cdot (1\, dz)
 = x^2 + \left(\frac{1^2} 2 - \frac{x^2} 2\right) = \frac{1 + x^2} 2.$$
