# How to calculate expected distance need to be covered to reach a vertex of right triangle from a section of opposite side?

Given a right triangle $\bigtriangleup BOC$ and distance $a, p, d$, what is the expected distance to needed to be traveled to reach $C$ from a point randomly selected on $AB$? (The distribution of point is uniform over $AB$)

$OB=p+a \\ AB=p \\ OC=d$

If I take the mean of $BC$ and $AC$ will the answer be correct? Also I tried,

$$\frac{\int_{a}^{a+p} \sqrt{x^2+d^2} dx}{p}$$

But, soon I realized I will be getting some area of $\bigtriangleup BAP$ not expected distance. Think about the case of $p=0$.

• You should describe what you have done to solve the problem and where you have failed. SE is not the place to get answers without trying to solve the problems first. – DirkGently Sep 15 '15 at 4:45
• What class is this in? As in, what methods are you expected to be using? – turkeyhundt Sep 15 '15 at 4:56
• Edited. I am not sure taking mean of BC and AC is the correct expected value. I need help on what other approaches can be taken or how can I be sure my calculation is correct? – Shakib Ahmed Sep 15 '15 at 4:56
• I think integration, but any correct procedure is ok. @turkeyhundt – Shakib Ahmed Sep 15 '15 at 4:58
• If I integrate the function sqrt(xx+dd) I will get the area of triangle BAC, not what I need. Rethink for case p=0. @turkeyhundt – Shakib Ahmed Sep 15 '15 at 5:00

The integration method is correct. You'll get: $$\frac1{2p}\left(x \sqrt{d^2+x^2}+d^2 \log \left(\sqrt{d^2+x^2}+x\right)\right)_a^{a+p}$$
Update: In this expression, we cannot let $p=0$ because throughout our calculations it is implicit that $p\neq0$. If $p=0$, the point becomes deterministic and so the distance is $\sqrt{a^2+d^2}$. We can get this by taking the limit as $p\to0$, by applying L'Hopital to the integral as the others have explained or to this expression (which is essentially the same): $$\lim_{p\to0} \text{distance}=\frac{\frac{d}{dp}\frac12\left((a+p) \sqrt{d^2+(a+p)^2}+d^2 \log \left(\sqrt{d^2+(a+p)^2}+(a+p)\right)\right)} {\frac{d}{dp}p}\\=\frac{\sqrt{a^2+d^2}}{1}={\sqrt{a^2+d^2}}.$$
Your integral is correct. The integrand is the distance given $x$, and you are taking the expectation given $x$ is $U[a,a+p]$. For the case $p=0$, you get $\sqrt{a^2+d^2}$ by L'Hopitals rule.
If the point randomly picked on $AB$ is $D$ with $BD=x$, then $x\in \mathcal{U}(a,a+p)\implies$ the expected distance to be covered is $$\mathbb{E}(DC)=\mathbb{E}\left(\sqrt{x^2+d^2}\right)=\int_{a}^{a+p}\frac{1}{p}\sqrt{x^2+d^2}dx$$ For the case $p=0$, the expectation becomes, $$\lim_{p\to 0}\int_{a}^{a+p}\frac{1}{p}\sqrt{x^2+d^2}dx=\lim_{p\to 0}\frac{\sqrt{(a+p)^2+d^2}}{1}=\sqrt{a^2+d^2}$$I have used L'Hospital's rule here to find this.