Projections of compact real algebraic sets Suppose that $M$ is a compact, real
algebraic subset of $\mathbb R^n$ and $f:\mathbb R^n \to \mathbb R^m$ is the projection to the first $m$ coordinates. If $f$ maps $M$ bijectively unto its image $f(M)$, is it true that $f(M)$ is algebraic?
 A: The answer is no. (Although the previous example I gave was bad.)
Let $C$ be the curve $y^2 = x^2 (x-1)(2-x)$, so $C$ has a smooth component with $1 \leq x \leq 2$, and also a node at $(0,0)$. Let $M$ be the normalization of $C$; explicitly,
$$M = \{ (x,y,z) : z^2 = (x-1)(2-x),\ y=xz \}.$$
Then the projection $M \to C$ is $1$-to-$1$ over the smooth component but misses the node.

However, such examples can only miss a set of lower dimension than $M$, and cannot occur if all connected components of the Zariski closure of $f(M)$ have the same dimension! This follows from
Bialynicki-Birula, A.; Rosenlicht, M., Injective morphisms of real algebraic varieties, Proc. Am. Math. Soc. 13, 200-203 (1962). ZBL0107.14602.
At the start of section 2, they prove the following result:

Let $V$ and $W$ be real algebraic sets and let $f: V \to W$ be an injective morphism such that $f(V)$ is Zarsiki-dense in $W$. Then $f(V)$ contains a Zariski-open Zariski-dense subset of $W$.

Note that this is very false for $f$ non-injective; consider the map $x \mapsto x^2$ from $\mathbb{R}$ to itself.
In our setting, take $V = M$ and let $W$ be the Zariski-closure of $f(M)$.  For simplicity, let $M$ be irreducible, so $W$ will be as well.
Bialynicki-Birula and Rosenlicht's result shows that $f(M)$ must contain a Zariski-open Zariski-dense subset $U$ of $W$, and thus $W \setminus U$ must be a proper Zariski closed subset of $W$. In particular, $W \setminus U$ must have dimension lower than $\dim W = \dim M$. If we now assume that $W$ is irreducible and all its connected components have the same dimension, then $U$ must be dense in $M$ for the analytic topology.
But, also, $f(M)$ is closed in the analytic topology since $M$ is compact. We have shown that $f(M)$ is closed for the analytic topology and contains a dense set (namely $U$) for the analytic topology, so $f(M) = W$.
