# Optimization with a Probability

Imagine two points in $ℝ^2$ at $(-1, 0)$ and $(1, 0)$. You would like to walk from one point to the next in the shortest distance possible. However, there is a line segment coming from the origin to a point $(0, S)$ and $(0,-S)$. In this instance, $S$ is a continuous uniform random variable picked between $0$ and $1$. You will not be able to how far the line goes up until coming into contact with it.

What follows is my work thus far on a solution. Let's say we walk the hypotenuse path to the center with a height $y$. Then, there are two scenarios when we get to the center: We have either walked under or over the center line.

In the case that we walked over the line, the optimal solution back from our point will simply be to walk in a straight line from $(0,y)$ to $(1, 0)$. Therefore, we will walk exactly $2\sqrt{1+y^2}$ meters.

In our second case, we have walked under the line. Now we will have to travel the remaining distance up the center line, and then walk on the hypotenuse from $(0,S)$ to $(1,0)$. Therefore, we will walk exactly $S-y+\sqrt{1+y^2}+\sqrt{1+S^2}$.

Since $S$ is a uniform continuous variable on the interval $[0, 1]$, we can write the probability that each of these events occur in terms of the value of $y$ that we choose.

• Specifically, $P(y>S)=y$ and $P(y<S)=1-y$.

Therefore, depending on our choice of $y$, the expected distance for us to travel can be modeled by:

$$y(S-y+\sqrt{1+y^2}+\sqrt{1+S^2})+(1-y)(2\sqrt{1+y^2})$$

And we need to minimize this function for $y\in 0\le y \le 1$. However, I have noticed that the second derivative of our expected distance is always negative for $y,S \in [0, 1]$. From this can I deduce that the best strategy will to always be to either go up to $(0, 1)$ or move in a horizontal line? This does not make sense to me.

Another possible error that I have found is that when I plug in a specific case for $S$, the expected distance walked does not make sense. For example, let's assume that $S=0$. In that case, the expected distance can be modeled by $$y(1-y+\sqrt{1+y^2})+(1-y)(2\sqrt{1+y^2})$$ For a chosen $y$ of $0$ meters, we get the expected value of $2$ expected meters. This makes sense. However, with a value of $y=1$, somehow the expected distance decreases to $\sqrt{2}$. This is obviously impossible.

I am sure that I have made a mistake somewhere in my logic. I am looking for any hints or different approaches to solve the problem. Thank you all for your time in reading this very long question!

• Is it "you will not be able to know how far"? – fonini May 5 '16 at 1:52
• That's correct. You won't know $S$ until you reach an $x$-value of $0$. – Will Sherwood May 5 '16 at 1:53
• When you say "the expected distance can be modelled by ...", you still have to take the expected value of that – fonini May 5 '16 at 2:01
• The expected value of that in terms of $S$? How would I go about changing $S$ in that expression then? – Will Sherwood May 5 '16 at 2:02
• I tried to explain it in my answer. Hope it helps. – fonini May 5 '16 at 2:14

If you were lucky enough to choose $y\geq S$, the distance will be $2\sqrt{1+y^2}$. Great. But if you weren't, the distance will be, as you said: $$d=\sqrt{1+y^2}+S-y+\sqrt{1+S^2}$$. Since this depends on $S$, the distance you will have to walk is itself another random variable. You didn't specify this in your statement of the problem, but I'll assume you want to minimize the expected distance. The expected distance is:

$$E\left[d\right]=P\left(\mathrm{y>S}\right)E\left[2\sqrt{1+y^2}\right] + P\left(\mathrm{y\leq S}\right)E\left[\sqrt{1+y^2}+S-y+\sqrt{1+S^2}\right]$$

This is:

$$E\left[d\right] = y\cdot 2\sqrt{1+y^2} + \left(1-y\right)\cdot\left[\sqrt{1+y^2}+0.5-y+E\left[\sqrt{1+S^2}\right]\right]$$

Now, the expected value of $\sqrt{1+S^2}$ is:

$$E\left[\sqrt{1+S^2}\right]=\int_0^1 \sqrt{1+s^2}\, ds$$

When you replace it in the equation, you will have a function depending only on $y$, which you can now try to minimize.

Using the value in the comments for this integral, I plotted the expected distance: You can see that if you choose to be greedy, going "straight ahead" at first, that is, $y=0$, you will walk on average approximately $1$ (to reach the origin) $+0.5$ (going up) $+1.1$ (to reach the destination). On the other side, if you don't want to risk having to go straight up, choosing $y=1$, you will just walk $\sqrt 2+\sqrt 2$.

• Using Wolfram Alpha and the fact that $\sinh^{-1}1=\log\left(1+\sqrt 2\right)$, the integral in my answer turns out to be $=\left[\sqrt 2+\log\left(1+\sqrt 2\right)\right]/2\approx 1.1478$. You should really just call this $C$ or something, and get a numerical answer in the end. – fonini May 5 '16 at 2:31

I would comment, but I don't have enough reputation. The only problem I see is you mixed up your probabilities for $P(y<S)$ and $P(y>S)$. They're actually reversed; in fact, $P(y<S)=1-y$ and $P(y>S)=y$. If you switch them, I believe the formula works fine; e.g. it gives $2\sqrt 2$ for $S=0,y=1$.

• Oh wow. And now the graph is concave up which means it can be minimized. Here is one step closer to the solution. I still am unsure on how to solve for the average case of $S$ though. – Will Sherwood May 5 '16 at 2:07
• @WillSherwood : You've calculated the cost of each choice of $y$ independently of $S$ (where each choice of $S$ is weighted uniformly). Since you know what $y$ minimizes the expected cost, ... – Eric Towers May 5 '16 at 2:09
• Although for $S=0$, $y=0$ gives $2$ and $y=1$ gives $2\sqrt{2}$, I still do not think the function works as intended. The minimum value is approximately $y=0.295$, which gives a distance value of 1.847. Again, this is not possible since the fastest distance is a straight line. I think it is technically you can't go "under" when $S=0$, and that will produce negative values for some $y$s. – Will Sherwood May 5 '16 at 2:10