Let $X_1,\ldots,X_n\sim {\rm Uniform}(0,1)$ and let $Y_n = \max\{X_1,\ldots,X_n\}$. FInd ${\bf E}(Y_n)$. This is exercise 3.3 from "All of Statistics".
I tried solving this in the case that $n=2$, but I found a solution that I feel is wrong. I'm not too great at integration, so I feel like that may be the problem. The problem then is to find 
$${\bf E}(Y_2)=\int^1_0\int^1_0\max(x,y)xy \;dx\;dy.$$
I tried splitting the double integral into two parts, where one is the section of the unit square with $x>y$ and the other $x\leq y$. I believe the correct integrals for this are
$$\int^1_0\int^{x/2}_0xy^2\;dy\;dx+\int^1_0\int_{y/2}^1 x^2y\;dx\;dy.$$
The left hand integral is equal to
$$\int^1_0x\int^{x/2}_0y^2\;dy\;dx - \int^1_0x\left(\frac{(x/2)^3}{3}\right)\;dx=\int^1_0x^2/24\;dx=1/72.$$
Similarly, we find on the right hand side that
$$\int^1_0\int^1_{y/2} x^2y\;dx\;dy = \int^1_0y\left[\frac{1}{3}-\frac{y^3}{24}\right]\;dy=17/96.$$
Together, these equal $5/24$. This doesn't seem right. What did I do wrong? Is my approach misguided? Also, how can I approach solving the problem in general?
 A: Let's first examine $Y_n = max\{X_1,X_2,...,X_n\}$. $P(Y_n<y) = P(max\{X_1,X_2,...,X_n\}<y)$. This means all individual $X_i<y$. Since they are independent of each other, we get:
$P(Y_n<y) = P(max\{X_1,X_2,...,X_n\}<y) = P(X_1<y)P(X_2<y)...P(X_n<y)=y^n=F_Y(y)$
$f_Y(y) = \frac{dF_Y(y)}{dy} = ny^{n-1}$
$\mathbb{E}Y_n=\int_0^1yny^{n-1}dy=\int_0^1ny^ndy$
A: We carry out your idea for the case $n=2$. (It could in principle be extended to the general case, but there are easier ways for general $n$.)
We want to find the double integral of $\max(x,y)$ times the joint density function, over the unit square. Note that this joint density is $1$ over the square.
As in your calculation, we split into two parts, (i) the triangle where $y\le x$ and (ii) the triangle with $y\gt x$.
For (i), the maximum of $x$ and $y$ is $x$. For the integration, $y$ goes from $0$ to $x$, and then $x$ goes from $0$ to $1$. So for (i) we want
$$\int_{x=0}^1\left(\int_{y=0}^x x\,dy\right)\,dx.\tag{1}$$
The inner integral is $x^2$, so the double integral is $\frac{1}{3}$.
We could similarly evaluate over the second triangle. That is just reversing the roles of $x$ and $y$, so by symmetry we get $\frac{1}{3}$.
It follows that $E(Y_2)=\frac{2}{3}$.
