Preamble:
I had asked this question a few days ago where people were saying that co-domain does not really matter in defining equal functions. When exactly are two functions said to be equal?
I saw your post the other day and contemplated answering, but felt (frankly) a bit lazy since it's a lot to get into and it can be painful to get this far in the weeds. Especially since this can be a bit of a confusing topic, I felt like fleshing out my comment a little more.
This is a matter of technicality, mostly...
Inverse Functions:
A function $f : A \to B$ can have three types of inverse functions:
- a left inverse, a function $f_L : B \to A$ such that $f_L \circ f = \mathrm{id}_A$
- a right inverse, a function $f_R : B \to A$ such that $f \circ f_R = \mathrm{id}_B$
- a two-sided inverse, or just inverse, a function $f^{-1}$ that is both a left and right inverse
Here, $\mathrm{id}_S$ is the identity function on $S$:
$$\begin{align*}
\mathrm{id}_S : S &\to S \\
x &\mapsto \mathrm{id}_S(x) := x
\end{align*}$$
It turns out:
- left inverses exist when a function is injective (one-to-one)
- right inverses exist when a function is surjective (onto)
- two-sided inverses exist when a function is both (bijective, or one-to-one correspondence)
Hence, in your post, $f,g$ both have a left inverse. That inverse can be given by the map $x \mapsto \ln x$. However ...
Functions & Function Equality:
Formally, a function is viewed as a tuple $
\newcommand{\d}{\operatorname{domain}}
\newcommand{\c}{\operatorname{codomain}}
\newcommand{\i}{\operatorname{image}}
(f,\operatorname{domain}(f), \operatorname{codomain}(f))$ where
- $\d(f),\c(f)$ are sets.
- $f$ is a relation between $\d(f)$ and $\c(f)$ (i.e. $f$ is a subset of $\d(f) \times \c(f)$).
- $f$ is a relation with the property that, if $x \in \d(f)$, then for exactly one $y \in \c(f)$, we have $(x,y) \in f$.
This final property meshes together several properties of relations, sometimes called "(left)-totality"/"seriality" and "functional."
The notation
$$
f : \d(f) \to \c(f)
$$
helps to more cleanly express the tuple, and to show which one serves which role. Similarly, the element $f(x)$ takes a notational role of the $y$ above. We may sometimes, through a sort of abuse of notation or common understanding, refer to $f$ as a function as we have for all of our lives, instead of as the relation, and speak of its codomain and domain as inherent objects tied to it.
So, this makes it clear then: Two functions $f,g$ are equal if and only if:
- $\d(f) = \d(g)$
- $\c(f) = \c(g)$
- $f(x) = g(x)$ for each $x \in \d(f) = \d(g)$
In your example, then, $f \ne g$ since their codomains are different.
Okay ... so what?
This focus on codomains is somewhat artificial. There are reasons it is useful, if just in terms of compactification or cleanliness, or focusing on simply on the larger set in which the values of $f$ lie. (Some discussion you might find insightful is here.)
Why do I call it artificial? Well, pretty much any set can be used for the codomain of a function $f$: be it $\i(f)$ or anything that it is a subset of! (This is what allows the compactifying of some notation, etc., as in the linked post: sometimes we just don't care about a precise statement of a function's image, sometimes we do. Sometimes we don't mind the loss of surjectivity; sometimes we do.)
It is further noteworthy that any function is surjective on its image, so - for the most part - if your concerns are just about invertibility, you only really care about injectivity. For your functions $f$ and $g$ described above, for all intents and purposes, they might as well share an inverse; it is just that $g$ is a function that restricts its codomain to its image, while $f$ does not.
Summarily, then, any injective function
$$
f : \d(f) \to \i(f)
$$
will have a left- and hence two-sided inverse
$$
f^{-1} : \i(f) \to \d(f)
$$
(It is also here you might see another convenience: if you change $\c(f)$ to something other than $\i(f)$, then the latter statement is untrue, and the composition of $f$ and its inverse might not be well-defined. Food for thought.)
In Summary:
- Functions have three things tied to them: not just their evaluation rule, but also a domain and codomain.
- Two functions formally are only equal when these three are the exact same things.
- Functions can have multiple kinds of inverses, tied to special properties like injectivity, surjectivity, and bijectivity. Your proposed inverse is an inverse for $g$, and its evaluation rule would play a role in a left inverse for $f$.
- Yes, we do technically care about codomain, but largely either for formalistic reasons (e.g. the formal definition of a function) or for aesthetic reasons (e.g. exact images can be hard to express and we sometimes just do not care about that level of detail/granularity) or sometimes we actually want to specify something (e.g. working with the real-valued logarithm and not diving into the technicalities of branches and such for the complex-valued one).
- Yes, codomain equality is required for two functions to be equal.
- However, in many cases, as stated, we just don't care about it. If we're discussing behavior of functions, for instance, we care a lot more about domains and evaluation rules and images, more than the codomain.
I hope this was able to clear up some confusion for you.
https://math.stackexchange.com/questions/4936505/when-exactly-are-two-functions-said-to-be-equal
– ca_100 Jun 25 '24 at 00:22