# Missing term in variational calculus problem

I was attempting to solve the following problem, adapted from this question: What is the optimal path between $2$ fixed points around an invisible obstructing wall? . My solution, however, is physically unintuitive because it does not depend on some apparently important parameters. I am looking for either a correction, or insight into why such a solution makes sense.

You are trying to get from point $\langle 0,0\rangle$ to point $\langle 1,0\rangle$ by the shortest possible path through the plane. Unfortunately, there is a chance that an invisible barrier will block your progress: With probability $p$, the barrier will not appear and your path will be unobstructed. However, with probability $(1-p)$, the invisible barrier will extend from point $\langle x,-h\rangle$ to $\langle x,+h\rangle$, where $x$ is uniformly chosen from the interval $(0,1)$, thus requiring you to walk around in order to pass. The barrier is infinitesimally thin, and because it is invisible, you cannot know its position or whether it's present unless you run into it.

Evidently if you run into the barrier, the optimal response is then to walk around the barrier then head in a straight line toward the goal. Before you run into the barrier, however, you must traverse some kind of path $f$. Find the (possibly curved) path $f$ which gives the shortest expected path length averaged over the existence and position of the wall.

I attempted to solve this using the calculus of variations, resulting in the following expression for the expected path length:

$$\int _{0}^1 p\cdot\sqrt{1+\dot{f}^2} + (1-p)(1-u)\sqrt{1+\dot{f}^2} + (1-p)(h-f(u)) + (1-p)\sqrt{h^2+(1-u)^2} du$$

Here, the four terms in the integrand correspond to:

1. Traversing $f$ from start to end unobstructed.
2. Traversing $f$ from start to the barrier's position at $u$.
3. Getting to the tip of the barrier.
4. Travelling in a straight line from the tip of the barrier to the end.

Strangely, if I use this integrand as my Lagrangian, the resulting Euler-Lagrange differential equation does not depend on the height $h$ of the wall in any explicit way:

$$0 = \frac{d}{du}\frac{\partial L}{\partial \dot f} - \frac{\partial L}{\partial f} = \frac{d}{du}\frac{[1-(1-p)u] \dot f}{\sqrt{1+\dot f^2}} - (1-p)$$

$$\frac{[1-(1-p)u]\dot f}{\sqrt{1+\dot f^2}} = -(1-p)u + C_0$$

Does this make sense, or does it indicate some mistake?

One thought I've had is that we implicitly assume $-h \leq f(u) \leq +h$ everywhere, because otherwise $f$ would be unnecessarily long. This constraint might be how the height of the wall and the optimal $f$ are related: if $h$ is so small that the supposedly optimal solution $f$ has $f(u) > h$ somewhere, then the optimal solution is actually $\min(h, f)$.