What is the expected length of the hypotenuse formed by bending a unit length randomly at a right angle? This is easy enough to simulate and find the answer is somewhere around .812. However I am not finding it so easy to solve the integral involved which I believe is...
$$\int_0^1 \sqrt{x^2+(1-x)^2} dx$$
I don't seem to get the right answer if I use this derivation. Bonus points for finding the expected area which is a much easier problem!
 A: You have $\sqrt{x^2+(x-1)^2}=\sqrt{2x^2-2x+1}=\sqrt2\sqrt{(x-1/2)^2+1/4}$. Take $m=x-1/2$ and the integral becomes$$2\sqrt2\int_0^{1/2}\sqrt{m^2+(1/2)^2}dm$$which is a standard form that evaluates to$$2\sqrt2\left[\frac m2\sqrt{m^2+(1/2)^2}+\frac{(1/2)^2}2\log\left|m+\sqrt{m^2+(1/2)^2}\right|\right]_0^{1/2}\approx0.812$$The expected area is similarly given by$$\frac12\int_0^1x(1-x)dx=1/12$$
A: $$\begin{align}I&=\int_0^1 \sqrt{x^2+(1-x)^2} dx\\
&=\int_0^1\sqrt{2x^2-2x+1}dx\\
&=\int_0^1\sqrt2\sqrt{\left(x-\frac12\right)^2+\frac14}dx\end{align}$$
Let $x-\frac12=\frac12\tan\theta$. Then, $dx=\frac12\sec^2\theta d\theta$.
$$\begin{align}I&=\frac{1}{2\sqrt2}\int_{-\frac{\pi}{4}}^{\frac{\pi}{4}}|\sec\theta|\sec^2\theta d\theta\\
&=\frac{1}{2\sqrt2}\int_{-\frac{\pi}{4}}^{\frac{\pi}{4}}\sec^3\theta d\theta\\
\end{align}$$
which can be integrated by parts.
Then,
$$\begin{align}I&=\frac{1}{2\sqrt{2}}\left(\frac12\sec\theta\tan\theta+\frac12\ln|\sec\theta +\tan\theta|\right)|_{-\frac{\pi}{4}}^{\frac{\pi}{4}}\\
&=\frac{1}{2\sqrt{2}}\left(\sqrt{2}+\frac12\ln\left|\frac{\sqrt2+1}{\sqrt2-1}\right|\right)\end{align}$$
A: Use the substitution $u=x-\frac{1}{2}$
$$\int_{-\frac{1}{2}}^{\frac{1}{2}} \sqrt{\left(u+\frac{1}{2}\right)^2+\left(u-\frac{1}{2}\right)^2}du = \int_{-\frac{1}{2}}^{\frac{1}{2}} \sqrt{2u^2 + \frac{1}{2}}du = 2\sqrt{2}\int_0^{\frac{1}{2}} \sqrt{u^2+\frac{1}{4}}du$$ 
Then there are two ways to approach this problem, either let $u=\frac{1}{2}\tan\theta$ or $u=\frac{1}{2}\sinh t$. Personally I find the second one easier as it doesn't require an integration by parts
$$ \frac{1}{\sqrt{2}} \int_0^{\sinh^{-1}\left(1\right)} \cosh^2 t dt = \frac{1}{2\sqrt{2}} \int_0^{\sinh^{-1}\left(1\right)} 1 + \cosh(2t) dt = \frac{1}{2\sqrt{2}}\Biggr[t + \frac{1}{2}\sinh(2t)\Biggr]_0^{\sinh^{-1}\left(1\right)}$$
$$=\frac{1}{2\sqrt{2}}\Biggr[t + \sinh(t)\cosh(t)\Biggr]_0^{\sinh^{-1}\left(1\right)}=\frac{1}{2\sqrt{2}}\Biggr[t + \sinh(t)\sqrt{1+\sinh^2(t)}\Biggr]_0^{\sinh^{-1}\left(1\right)}$$
$$ = \frac{\sinh^{-1}\left(1\right)}{2\sqrt{2}} + \frac{1}{2} \approx 0.8116$$
by using the hyperbolic identities $\cosh(2t) = \cosh^2(t) + \sinh^2(t)$ and $\cosh^2(t)-\sinh^2(t) = 1$.
