$U \sim U(0,1)$
Define $X = \text{max}\{U, 1-U\}$
so that
$$X =
\begin{cases}
1-U, & 0 < U < 1/2 \\
U, & 1/2 \leq U < 1
\end{cases}
$$
It follows that
$$X = \frac{1 + |2U - 1|}{2}$$
$$F_X(x) = P (X \leq x), \:\:\:\: 1/2 < x < 1$$
$$=P\left(\frac{1 + |2U - 1|}{2} \leq x \right)$$
$$=P(|2U - 1| \leq 2x-1)$$
$$=P(-2x+1 \leq 2U - 1 \leq 2x-1)$$
$$=P(1-x \leq U \leq x)$$
$$=P(1-x < U \leq x)$$
$$=F_U(x) - F_U(1-x)$$
Differentiating with respect to $x$:
$$f_X(x) = f_U(x) + f_U(1-x), \:\:\:\:\: \text{for}\:\:\: 1/2 < x < 1$$
It follows that
$$f_X(x) =
\begin{cases}
2, & \text{if}\:\:\:1/2 < x < 1, \\
0, & \text{otherwise}
\end{cases}
$$
and since we have for a uniform variable
$$f_Z(z) =
\begin{cases}
\frac{1}{b-a}, & \text{if}\:\:\:a < z < b, \\
0, & \text{otherwise}
\end{cases}
$$
$$E[Z] = \frac{b+a}{2} $$
It follows that
$$E[X] = \frac{1 + 1/2}{2} = \frac{3}{4} $$
Let $X$ be the length of the longer of the two pieces. As you say, $X$ is uniformly distributed on $\left[\frac12,1\right]$ with density $2$
Let $Y$ be the length of the shorter part of $X$. If $X=x$ then $Y$ is uniformly distributed on $\left[0,\frac{x}2\right]$ with density $\frac2{x}$ when $0 \le y \le \frac{x}{2}$, and $\mathbb E[Y \mid X=x] = \frac{x}{4}$
So we can say the marginal density for $Y$ on $\left[0,\frac{1}2\right]$ is $$f(y)=\int\limits_{\mathbb R}\frac2{x} \mathbb I\left[0 \le y \le \frac{x}{2}\right] 2 \mathbb I\left[\frac12 \le x \le 1\right]\,dx= \int\limits_{x=\max(2y,1/2)}^{1}\frac4{x} \,dx$$ using indicator functions, and this is $4{\log_e(2)}$ when $0 \le y \le \frac{1}{4}$ and is $-4{\log_e(2y)}$ when $\frac14 \le y \le \frac{1}{2}$
Similarly $$\mathbb E[Y] = \int\limits_{\mathbb R}\frac{x}4 2 \mathbb I\left[\frac12 \le x \le 1\right]\,dx=\int\limits_{x=1/2}^{1}\frac{x}2\,dx= \frac3{16}$$ and as a check $\int\limits_{y=0}^{1/2} y\, f(y) \, dy$ gives the same result
Best Answer
Let $Y$ be the length of the largest stick and $X$ be the distance from the left end where the stick is broken. $Y=2-X$ if $0\le X\le 1$ and $Y=X$ else. We need to find $E(Y)$.
$$E(Y)=\int_0^1 \frac{2-x}{2}dx+\int_1^2 \frac{x}{2}dx$$