First order decidability of limit of gradient flow? Let $f: \mathbb{R}^n\to\mathbb{R}$ be a polynomial function, and let $p$ be a critical point. Consider the ascending manifold $A_p$ consisting of all points whose limit under the gradient flow of $f$ is equal to $p$. Is $A_p$ a semialgebraic set? If not, is there an additional assumption on $f$ that makes it so? 
This is an offshoot of a previous question of mine that did not get much attention. 
 A: Overview: The boundaries of the basins of attraction are lower dimensional stable manifolds. In two dimensions, they are the arcs flowing from repelling fixed points to saddle points. I expect that these are basically never analytic near the repelling fixed point. More specifically, if $f(x,y) = \alpha x^2 + \beta y^2 + (\mbox{higher order terms})$, then $dx/dt  \approx 2 \alpha x$ and $dy/dt \approx 2 \beta y$, so the solution to the differential equation is roughly $x \approx \exp(2 \alpha t)$ and  $y \approx \exp(2 \beta t)$, giving $x \approx y^{\beta/\alpha}$. If $\beta/\alpha$ is irrational, then this can't be algebraic.
Here is a case where I can make this analysis precise. Let
$$f(x,y) = a x^2 (1-x^2/(2p^2)) + b y^2 (1-y^2/(2 q^2)) - c x^2 y^2$$
with $a$, $b>0$, $a/b$ irrational and $c > \max(a/p^2, b/q^2)$. Then $f$ has a repelling fixed point at $(0,0)$ (if Morse flow goes up hill), has attracting fixed points at $(\pm p, 0)$ and $(0, \pm q)$, and has a saddle point in each quadrant. The $x$ and $y$-axes are flow lines, so none of the other flow lines can cross them. I claim that none of the other flow lines through $(0,0)$ are analytic at $(0,0)$. I'll analyze the case of a flow line through the first quadrant, so $x(t)$, $y(t)>0$.
The Morse flow equation is
$$\begin{bmatrix} dy/dt \\ dx/dt \end{bmatrix} = \begin{bmatrix} \partial f/\partial y \\ \partial f/\partial x \end{bmatrix} = \begin{bmatrix}  2y (b-by^2/q^2 - c x^2) \\ 2x (a - bx^2/p^2 - c y^2) \\ \end{bmatrix}. $$
This means that
$$\frac{d \log y/dt}{d \log x/dt} = \frac{y^{-1} d y/dt}{x^{-1} d  x/dt} =  \frac{b-by^2/q^2 - c x^2}{a - ax^2/p^2 - c y^2}.$$
So, by L'Hospital, on any flow line where $x$ and $y \to 0^+$, we have 
$$\frac{\log y}{\log x} \to \frac{b}{a}.$$
If the flow line were an algebraic arc, then $\tfrac{\log y}{\log x}$ would approach a rational limit, a contradiction. 
In particular, the flow from $(0,0)$ to the saddle point in the first quadrant is the boundary between the basins of attraction of $(p,0)$ and $(0,q)$, and is not algebraic.
Again, I don't think this example is special. I think it is just unusual in that I can carefully analyze the behavior as $(x,y) \to (0,0)$, since $x$ and $y$ divide $\tfrac{\partial f}{\partial x}$ and $\tfrac{\partial f}{\partial y}$.
Here is a picture. I took $p=1$, $q=1.1$ and $(a,b,c) = (0.2633, 0.4733, 1)$. Those values were chosen to make the attracting fixed points look like $-c(x^2+y^2)$, so the flow comes into them without any funny nodes.

