A locally injective but non globally injective function?

A continuous function $f : U \subset \mathbb{R}^n \to \mathbb{R}^n$, is said to be locally injective at $x_0 \in U$ if exist a neighborhood $V \subset U$ of $x_0$ s.t. $f|_V$ is injective. $f$ is said to be locally injective on $U$ if is locally injective at all points of $U$.

If $n=1$, clearly $f$ is locally injective on $U$ iff it's injective on $U$. If $n >1$, this is false (at least is what I believe).

Does anybody know a counterexample i.e. a continuous function which is locally injective on an open $U$ set but it's not injective on $U$?

[observation] if $f$ is locally injective, by the invariance domain theorem is a local homeomorphism. if $f$ is also proper (i.e. the counter-image of a compact set is compact), then it's also a global homeomorphism (Caccioppoli theorem), and consequently injective. This means the counterexample cannot be a proper map.

 I forgot to specify that I was interested in continuous functions.

-
A condition on the function might be missing. Otherwise, in dimension 1, the function "fractional part" is locally injective but not injective on R. – Did Aug 19 '11 at 11:06
Look at $z \mapsto z^2$ on $\mathbb{C}\smallsetminus \{0\}$, for example. – t.b. Aug 19 '11 at 11:07
@Didier Piau: you are right, I was thinking about continuos functions. – Angelo Lucia Aug 19 '11 at 11:22
What is $U$? ${}$ – Pierre-Yves Gaillard Aug 19 '11 at 11:33
"If $n=1$, clearly $f$ is locally injective on $U$ iff it's injective on $U$." What about $U = (0,1) \cup (1,2)$ and $f|_{(0,1)} = \mathrm{id}$, $f|_{(1,2)}= \mathrm{id} - 1$? – Sam Aug 19 '11 at 11:37

An easy way to find such an example is to take any non-constant holomorphic function $f:U \to \mathbb{C}$ and throw away the points where $f' = 0$. A holomorphic function is locally injective if $f'(z) \neq 0$, so we need only ensure that the function is not globally injective.

As I pointed out in a comment, we can take $U = \mathbb{C} \smallsetminus \{0\}$ and $f(z) = z^n$ for $n \geq 2$. Or, if you prefer, $f(z) = e^z$ on all of $\mathbb{C}$ for the most simple-minded examples.

These examples are easily extended to $\mathbb{R}^n$, $n \geq 2$, simply by writing $\mathbb{R}^n = \mathbb{C} \times \mathbb{R}^{n-2} \ni(z,v)$ and considering $g(z,v) = (f(z), v)$. I'll leave it to your creativity to build many more and more interesting examples.

-

Let $U\subset\mathbb{R}^2$ be the set $\{(x,y)|1\lt x\lt2 \& 0\lt y\lt7\}$ and $f$ be $(x,y) \mapsto (x\times\sin(y), x\times\cos(y))$ . $f$ is locally injective on $U$ but $f(1,0)=f(1,2\pi)$.

-

Let UR, and let f: UR $\to R^2$ be t $\to$ ($t^2$ - 1 , t($t^2$ - 1)). It is locally injective at all points of R, but not injective in any interval (-a,a) with $a\gt 1$, because f(-1)=f(1)=(0,0)

-