Hill climbing extremist Imagine you are on a trip in mountains, but you are a bit nutter and you walk only straight uphill or downhill. If you are on the top of a mountain or in a valley you can walk in any direction.
The question is: Can you get from any point to any another point?

In more mathematical language. Imagine you have a smooth function $\phi:\mathbb{R}^2\rightarrow\mathbb{R}$. In order to dismiss simple counter examples we require that $\phi$ coercive or is zero at infinity. Now be given two points $A,B \in \mathbb{R}^2$, can you find piece-wise smooth curve $\gamma(t)$ such that $\gamma'$ has the same or opposite direction as $\nabla \phi(\gamma(t))$, except at the points where $\nabla \phi = 0$? This can be stated, after reparametrization of $\gamma$, as $|\gamma' \cdot \nabla \phi| = \|\gamma'\|\|\nabla \phi\|$.

Background: I was thinking about this differential equation for $u$
$$
f = g_i \partial_i u.
$$
you can find local solution of by integrating the function $f$ along integral curves of $g_i$. But when can you glue these solutions together and get a globally continuous solution? This should be possible when you can get from point $A$ to point $B$ by different paths but you integrate the same amount of $f$. So natural question is, can you get from any point $A$ to any point $B$?
I found this question interesting but surprisingly I was unable to find a (simple) argument why it should be true.
 A: I haven't thought this through, but at the same time it would take too much space as comment, so let me describe an idea I have for this problem.
$\newcommand{\R}{\mathbb{R}}\newcommand{\vp}{\varphi}$
Idea. The relation $x \sim y$ if there is a path joining $x$ and $y$ is an equivalence relation in $\R^2$. If you can only prove that each equivalence class is open, then your claim follows from connectedness of $\R^2$.
Other observations:

*

*I would expect that one needs some assumptions on behavior of $\vp$ in infinity, so it could be easier to work on a torus or a sphere first, and then see what is needed in the case of $\R^2$.

*It is surely important that our vector field is a gradient field. On a torus any nonzero constant vector field yields a counterexample, so one probably needs to use the growth of $\vp$ in some way.

*To make things clearer, I would add an additional assumption that $\vp$ is a Morse function. This way we can be sure what happens at points where $\nabla \vp = 0$.

A: Well, in general the answer is no. It will depend on the regularity of $\phi$ and on the points $A$ and $B$. Your problem is a particular case of the following problem:

Given a continuous vector field $X: \mathbb{R}^2 \rightarrow \mathbb{R}^2$ and points $A,B\in\mathbb{R}^2$, is there a curve $\gamma: [0,1] \rightarrow \mathbb{R}^2$ with $\gamma(0)=A$, $\gamma(1)=B$ and $\gamma'(t) = X(\gamma(t))$, for every $t\in(0,1)$?

In your case, $X$ is the gradient field $X = \nabla \phi$.
If we drop the condition $\gamma(1)=B$, then we have  Cauchy-Peano Theorem. But we can't ensure that $\gamma(1) = B$ in general. For example, let's consider the constant vector field $X = (1,0)$ (notice that $X$ is also a gradient field) and let $A=(0,0)$ and $B=(0,1)$ be the points. It's easy to verify that there is no curve $\gamma$ with $\gamma(0) = A$, $\gamma(1)=B$ and $\gamma'(t) = (1,0)$, for every $t\in(0,1)$. Now this example doesn't vanish in the infinity, but you can get the idea to convince yourself. The point is that once you have the field $X$, the integral lines will be determined. So if you don't have at least $A$ and $B$ on the same integral line, you will not have a solution passing through them.
