TITLE: A polynomial with nowhere surjective derivative
QUESTION [25 upvotes]: Let $P:\mathbb {R}^2\rightarrow \mathbb {R}^2$ be a polynomial map. It is given that the Jacobian of $P$ is everywhere not surjective. Must  the following  be true:
There exist polynomial maps $f:\mathbb {R}^2 \rightarrow \mathbb {R}$ , $g:\mathbb {R} \rightarrow \mathbb {R}^2$ such that $P= g \circ f $.
Thank you.
The reason why I put the tag abstract algebra instead of differential geometry tag only is because I am asking for the existence of morphisms which are polynomial maps and not just any morphisms in the category of smooth manifolds.

REPLY [14 votes]: As a disclaimer, I will follow an "algebraic geometer" approach. Thus, all the morphisms will essentially be polynomials (or rational functions).
To be short, my answer is "yes". The exaplanation is a bit long though.
Let me start with a remark on your comment about the argument working over different fields. Over an algebraically closed field of characteristic zero (e.g., $\mathbb C$), there are tools that replace the implicit function theorem. That is, if we have a morphism between smooth varieties, the dimension of the image should match the maximal rank of the jacobian. In particular, in your case, the image of $P$ will be either a curve or a point (we know it by base changing to $\mathbb C$, as $\mathbb R$ is not algebraically closed). On the other hand, this is not true over fields of characteristic $p > 0$. In particular, the Frobenius morphism from a variety to itself (so, from $k^2$ to itself, if $k$ is a field of positive characteristic) is a dominant morphism (that is, the image is dense. It is surjective if $k$ is perfect) whose differential is identically zero. Indeed, this morphism is defined as $x \mapsto x^p$, and its differential is $p \cdot x^{p-1}dx$, which is $0$ as $p=0$. Thus, if we take the Frobenius for $k^2$ with $k$ a field of positive characteristic, the claim in your question does not hold.
Now, let me assume that we are working over an algebraically closed field of characteristic zero. In particular, we may assume that $k=\mathbb C$. We will use this case to deduce something about the case $k = \mathbb R$.
Now, by the discussion above, we know that the image has dimension 0 or 1. If it has dimension 0, then your claim follows, as we can take $f \colon k^2 \rightarrow k$ and $g \colon k \rightarrow k^2$ to be suitable constant polynomials. Thus, I will assume that the image has dimension 1.
By the above reductions, we know that the image of $P : k^2 \rightarrow k^2$ is a curve $C$. This curve $C$ may be singular. On the other hand, as $k^2$ is smooth, we know that $k^2 \rightarrow C$ factors as $f \colon k^2 \rightarrow T$ and $g \colon T \rightarrow C \subset k^2$, where $T$ is smooth (here $T$ is the normalization of $C$). Now, as $k^2$ is a rational variety (it can be compactified to be $\mathbb P ^2_k$, the projectiva plane over $k$), $T$ is unirational (essentially by definition of unirational). As $T$ has dimension 1, the solution to the Lüroth problem in dimension 1, it follows that $T$ is rational. That is, $T$ is an open subset of the projective line $\mathbb P ^1_k$.
Furthermore, as $T$ maps to $k^2$, it can not be compact. Thus, $T$ is an open subset of the affine line $k$. As the topology I am using is the Zariski topology, it means that $T$ is $k$ with possibly a finite number of points removed.
By the comment of David Speyer below, we can then conclude that $T=k$. Indeed, if $T$ was strictly contained in $k$, $T$ would admit non-constant units in its coordinate ring. Then, these functions would pull back to $k^2$ along the morphism $k^2 \rightarrow T$, providing some non-constant units in $k[x,y]$, which is a contradiction.
Thus, to summarize, we got a morphism $f \colon k^2 \rightarrow k$, and a morphism $g \colon k \rightarrow C \subset k^2$. As we are dealing with algebraic varieties, and as $f$ has domain $k^2$ and target $k$, $f$ is a polynomial. Similarly, $g$ is a polynomial too.
Now, let's go back to your $P$ defined over $\mathbb R$. By base change to $\mathbb C$, we can regard $P$ as a morphism $P_\mathbb{C} \colon \mathbb C ^2 \rightarrow \mathbb C ^2$ (basically, you keep the same polynomials, and input complex values). As the image of $P_\mathbb{C}$ has dimension 1, so does the image of $P$. Furthermore, the image of $P_\mathbb{C}$ is obtained from the image of $P$ by "base change to $\mathbb{C}$". This guarantees that what we concluded over $\mathbb C$ still holds over $\mathbb R$.
Let me conclude with a remark. We heavily relied on the fact that we were interested in $k^2$. This guaranteed that the image of $P$ was a point or a curve. To treat the curve case, we used Lüroth's theorem. This guarantees that every unirational curve is rational. This is not true in higher dimension: it is still true for surfaces in characteristic zero, but it fails even over $\mathbb C$ in higher dimension. Thus, I do not expect this argument to generalize for morphisms $P \colon k^n \rightarrow k^n$ with $dP$ never surjective.