Dividing a rope into three random pieces. Expected longest length A rope of 1m is divided into three pieces by two random points. Find the average length of the largest segment.
This question has been answered here:
Average length of the longest segment
Someone had a solution:
let the cuts be at $X, Y$, with $Y \gt X$:
Image of cut positions
Then each piece is equally likely to be the longest, and the expected length of the longest piece doesn't depend on which piece we choose. Then we can calculate $\mathop{\mathbb{E}}(X|X \text{ is the longest piece} )$.
We have the three inequalities:
$$X \gt Y-X \implies Y < 2X$$
$$X \gt 1-Y \implies Y > 1-X$$
and, from our setup,
$$Y \gt X$$
These can be represented by the following diagram:
Diagram of inequalities
Then the area satisfying our inequalities is the two triangles A and B. So we wish to find the expected value of $X$ within this area.
The expected value of $X$ in A is $\bar{X}_A = \frac{1}{2}-\frac{1}{3}(\frac{1}{2}-\frac{1}{3}) = \frac{8}{18}$.
The expected value of $X$ in B is $\bar{X}_B = \frac{1}{2}+\frac{1}{3}(\frac{1}{2}) = \frac{4}{6} = \frac{12}{18}$
The area of A is $A_A = \frac{1}{2} \times \frac{1}{2}\times (\frac{1}{2}-\frac{1}{3}) = \frac{1}{24}$.
The area of B is $A_B = \frac{1}{2} \times \frac{1}{2}\times \frac{1}{2} = \frac{1}{8} = \frac{3}{24} = 3 A_A$.
So $\mathop{\mathbb{E}}(X|X \text{ is the longest piece} ) = \frac{\tfrac{8}{18} + 3\left(\tfrac{12}{18}\right)}{4} = \frac{11}{18}$
I understand everything but I got lost when he said calculate expected value of $X$ within triangles. How do you exactly find the expected value of $X$ over the triangle $A$ and $B$? How did he come up with $\mathop{\mathbb{E}}(X|X \text{ is the longest piece} )$?

In your problem, $\bar{X}_A$ is the $x$-coordinate of triangle A's center. To calculate it, use that the center of a triangle is situated at $1/3$ of any edge center.
