Can two functions with different codomains be equal?

I'm looking through some lecture notes, and found that the author defined two functions f and g to be equal if:

• they have the same domain, say S,
• they have the same codomain, and
• f(x)=g(x) for all x in S.

This seems peculiar to me. In the notation of relations, for instance, this implies that

• the relation $R=\{(t,\sqrt{t}): t \in \mathbb{R}^{\geq 0}\} \subseteq \mathbb{R}^{\geq 0} \times \mathbb{R}$ and
• the relation $R'=\{(t,\sqrt{t}): t \in \mathbb{R}^{\geq 0}\} \subseteq \mathbb{R}^{\geq 0} \times \mathbb{R}^{\geq 0}$

are not equal (despite $R=R'$).

Question: Is there any reason to define two functions as non-equal based solely on their codomains?

-

It can be convenient to require that codomains are part of the definition of a function. For example, when speaking of surjectiveness: If $f=g$ and $f$ is surjective, then $g$ is surjective, but only if we are careful to require that equality implies having the same target set.

The first function you defined is not surjective. The second one is, and in fact it is invertible.

Similarly, the inclusion $\mathbb Z\to\mathbb R$ is for some purposes different from the identity map $\mathbb Z\to\mathbb Z$.

It is true that in many contexts it hardly matters. You might be interested in this MathOverflow question coming from a case where the distinction was considered important.

-
Thanks for that. Makes sense, although this suggests that the relation-based definition should (strictly speaking) include the domain and codomain along with the relation itself. –  Douglas S. Stones Dec 16 '11 at 7:53
@Douglas: Bourbaki and many categorically inclined people include domain and codomain in the definition of a function whereas many set-theoretic texts don't adhere to that convention. See also this MO thread. –  t.b. Dec 16 '11 at 8:05
Thanks, that's very helpful. –  Douglas S. Stones Dec 16 '11 at 9:28