Is the function $f\colon x\to x^2$ one-one or onto or both on a set of rational numbers, real numbers and complex numbers?

We can easily see that the function $f\colon x\to x^2$ is not one-one or onto on the set of integers. Though it is one-one if defined on the set of positive integers. I wanted to know if the function is one-one or onto or both on a set of rational numbers, real numbers and complex numbers?

-
Well, either be more specific on this set you look for, or else just take $\{0\}$. Besides, the set of positive integers is also a set of rational, real or complex numbers. –  Andrea Mori Aug 28 '12 at 20:34

Clearly on the rationals $x\mapsto x^2$ is not one-to-one since $-2$ and $2$ are both mapped to $4$, it is also not onto because there is no rational number such that $x^2=-1$.

By this the function is also neither one-to-one nor onto the real numbers, and it therefore cannot be one-to-one over the complex numbers. However it is onto the complex numbers because every complex number has a square root, by the virtue of the complex numbers being an algebraically closed field.

On the other hand, if we only consider positive rationals then the function is one-to-one, although it is not onto because $\sqrt 2$ is not in the image; but on the positive real numbers the function is both one-to-one and onto.

-
You don't need to know that $\mathbb{C}$ is algebraically closed in order to deduce the existence of square roots. –  Harald Hanche-Olsen Aug 28 '12 at 20:36
@Harald: How else would you deduce that $x^2-t$ has a root for every $t$ in the field? –  Asaf Karagila Aug 28 '12 at 20:37
For example by writing a given complex number in polar form as $re^{i\theta}$. Then the square roots are $\pm\sqrt{r}e^{i\theta/2}$. –  Harald Hanche-Olsen Aug 28 '12 at 20:40
@Harald: But why is this a well-defined complex number? Not every field is an exponentially closed field. –  Asaf Karagila Aug 28 '12 at 20:41
But we're not talking about every field. This is all about $\mathbb{C}$, which is a very concrete object assuming you know a few things about the real numbers. –  Harald Hanche-Olsen Aug 28 '12 at 20:44
The question is unclear, so I'll interpret it as asking for a subset $S$ of the complex numbers such that $f(x)=x^2$ is defined, one-one, and onto as a function from $S$ to $S$.
First note that the empty set, the set containing only zero, the set containing only one, and the set containing only zero and one all work, and if $S$ works then the union of $S$ with any of those sets also works. So that's settled, and we can ignore zero and one from here on.
Here's another set that works: $$\dots,2^{1/8},2^{1/4},2^{1/2},2,2^2,2^4,2^8,\dots$$ Viewing this as a sequence, $f$ is just a shift one slot to the right, and clearly one-one and onto.
Now there's nothing special about 2 here; we could start with any complex number $a$ and do $$\dots,a^{1/8},a^{1/4},a^{1/2},a,a^2,a^4,a^8,\dots$$ although we have to make some choices as to how we define the numbers to the left of $a$ if $a$ is not a nonnegative real number. What's more, we can take the union of any number of these sets for different values of $a$ and get another set $S$ that works. And that's as general an answer as you're going to get.
Now if you want all the elements of $S$ to be rational, you're stuck with $\{\,0,1\,\}$ and subsets thereof, because if $S$ has anything else in it then if you take enough inverse images ("square roots") you're guaranteed to hit an irrational. If you want all the elements of $S$ to be real, take only non-negative values of $a$.