Determine if function is well defined I am having difficulties determining if the following function is well defined:
On certain computers the integer data type goes from $-2, 147, 483, 648$ through $2, 147, 483, 647$. Let S be the set of all integers from $-2, 147, 483, 648$ through $2, 147, 483, 647$. Try to define a function $f:S  -> S$ by the rule $f(n) = n^2$ for each n in S. Is f well defined? Why?
Side notes:
I am learning how to determined whether a function is well defined. I am doing so by relying on two disticnt reasons that show a not well defined function: (1) There is no y that satisfies  the given equation or (2) there are two different values of y that satisfy the equation. 
 A: $n = 2, 147, 483, 647 \in S$.
Is there any $f(n) = y \in S$ such that $$y = (2, 147, 483, 647)^2\quad?$$
Indeed, for any integer $n \gt 46340, n^2 \notin S$.
How does this relate to the first reason you give for a function not being well-defined?
A: With $S = [-N, N - 1] \cap \mathbb{Z}$, the function defined on $S$ by the rule $f(n) = n^2$ will not give values back in $S$ for any $N > 1$, so you cannot have the $f:S \to S$.  (You are using the particular value $N = 2^{31} = 2147483648$.)
However, usually when one is concerned with a function $f: A \to B$ being well-defined, it is because the elements of the domain set $A$ do not have a unique representation.
Here is an example of a function that is not well-defined to illustrate this idea.  Let $n: \mathbb{Q} \to \mathbb{Z}$ be the function that extracts the numerator of a fraction.  If $x = \frac{a}{b} \in \mathbb{Q}$ (say, with $a, b \in \mathbb{Z}$), then $f(x) = a$.
It's easy to see that even though, for example, $\frac{2}{3} = \frac{4}{6}$, the formula seems to say that the value of the function ought to be $2$ or $3$, depending on which representation of the number you choose.
By the way, this idea can be salvaged.  You have to insist on the $\gcd(a, b) = 1$ and $b>0$, so that the fraction has a unique representation.  I digress...
A: In order for a function, say $g:A \to B$, to be well defined it must map into its codomain ($B$, in the case of $g$).
