TITLE: What are well-defined functions?
QUESTION [26 upvotes]: What exactly makes a function well-defined? I have seen some proofs but they are too hand-wavy and I couldn't understand exactly what a well-defined function is.

REPLY [9 votes]: A function $f:A\to B$ is, by (the ordinary) definition, a relation $f\subseteq A\times B$ with two properties:

For all $a\in A$, there exists a $b\in B$ such that $f(a)=b$
For all $a,a'\in A$, if $a=a'$, then $f(a)=f(a')$.

The second axiom is what makes a function "well-defined." There is no proof needed to show that "functions are well-defined," (they are well-defined by definition!) BUT quite often we have a rule we invented making a relation, and we need to prove "this relation has properties 1 and 2, so it is a well-defined function."
When defining a function on the set of equivalence classes $E$ from an equivalence relation on a set $X$, it is natural to define functions only in terms of elements of $X$ and then ask if they are still functions on $E$. This isn't automatic, however, and my favorite example showing why it's not automatic has already been given by MJD above.
Quite simply, one can't just assume every relation we come up with in terms of $X$ makes a function on equivalence classes of an equivalence on $X$.