# Compute $E[\max (X,Y)]$ for $X$ standard exponential, $Y$ uniform on $[0,1]$, $(X,Y)$ independent

Suppose $$X$$ is exponential with mean $$1$$ and $$Y$$ uniform on $$[0,1]$$ and they are independent. Calculate $$\mathbb{E}[\max (X,Y)]$$

### Try

As they are independent, we can easily calculate the joint density $$f_{X,Y}(x,y) = 1 \cdot e^{-x} = e^{-x}$$. Therefore,

$$\mathbb{E}[ \max(X,Y) ] = \int \int \max(x,y) e^{-x} dx dy$$

We have to consider cases now:

$$\max(x,y) e^{-x} = \begin{cases} x e^{-x}, & y

Thus,

if $$y, we obtain

$$\int\limits_0^1 \int\limits_y^{\infty} x e^{-x} dx dy = \frac{1}{e}-2$$

Now, if $$x, then

$$\int_0^1 \int_0^y y e^{-x} dxdy = \frac{2}{e} - \frac{1}{2}$$

Thus the required expectation is

$$\boxed{ \frac{3}{e} - \frac{5}{2} }$$

Is this a correct solution?

Your solution cannot be correct because $$e > 2$$ implies $$6 - 5e < 0$$, thus $$3/e - 5/2 < 0$$, and the expectation cannot be negative since neither $$X$$ nor $$Y$$ are ever negative.
Looking more closely at your computation, it is the first iterated integral that is incorrect, again simply by checking the sign, since $$1/e < 1$$ hence $$1/e - 2 < 0$$. We have instead \begin{align*} \int_{y=0}^1 \int_{x=y}^\infty x e^{-x} \, dx \, dy &= \int_{y=0}^1 \left[ -(1+x) e^{-x} \right]_{x=y}^\infty \, dy \\ &= \int_{y=0}^1 (1+y)e^{-y} \, dy \\ &= \left[ -(2+y)e^{-y} \right]_{y=0}^1 \\ &= -\frac{3}{e} + 2. \end{align*} The second integral is correct, hence the result should be $$\operatorname{E}[\max(X,Y)] = \frac{3}{2} - \frac{1}{e},$$ and this value is positive.
The following Mathematica code estimates this expectation from $$10^7$$ simulations:
Mean[Max[#, RandomReal[]] & /@ RandomVariate[ExponentialDistribution[1], 10^7]]