12
$\begingroup$

So I read from various sources that a function can be defined as a binary relation. Then is it valid to say, for example, $f = \{ (1, 2), (2, 3) \}$?

And suppose I have another function $g = \{ (4, 5) \}$. Does it then make sense to write $(f \cup g)(2) = 3$?

$\endgroup$
13
  • 9
    $\begingroup$ @ShyamalSayak See en.wikipedia.org/wiki/Function_(mathematics). What's unclear? A function $f$ is defined by the domain $X$, the codomain $Y$ and the set of values $\{(x, f(x)), x\in X\}$. $\endgroup$ Commented Feb 18 at 21:44
  • 6
    $\begingroup$ Yes to all your questions. But if you do write $f =\{(1,2),(2,3)\}$ instead of $f:\{1,2\}\to\mathbb R,\, x \mapsto x+1$, everyone will know that you are a set theory fundamentalist. $\endgroup$
    – Stef
    Commented Feb 18 at 21:47
  • 9
    $\begingroup$ What you are doing is not entirely valid, as a function is not defined only by the set $\{(x,f(x))\}$. One may argue that the domain can be recovered as the set of first elements of each pair. However, the codomain isn't available. But if you define $f\cup g$ more precisely it will make sense. Note that you have also to assume that the intersection of the domains of $f$ and $g$ is empty (otherwise $f(x)$ would not be uniquely defined). $\endgroup$ Commented Feb 18 at 21:48
  • 8
    $\begingroup$ @Jean-ClaudeArbaut: the standard set-theoretic representation of a function is as a set ot pairs. Your comment is not correct in that context. $\endgroup$
    – Rob Arthan
    Commented Feb 18 at 21:53
  • 5
    $\begingroup$ Bourbaki's Theory Of Sets, E.II.13, for instance. A function $f$ is defined by the domain $X$, the codomain $Y$ and a subset $F$ of $X\times Y$ that is a functional graph. If you prefer, $f=(X,Y,F)$. You seem to be confusing the graph and the function. And yes, the graph is not taken in isolation. $\endgroup$ Commented Feb 18 at 22:16

3 Answers 3

29
$\begingroup$

In the language of set theory, using the standard representation of function as sets of pairs, you are exactly right. Your $f$ and $g$ are both functions, as is $f \cup g$, and $(f \cup g)(2)=f(2) = 3$.

In general, the union of any two functions $f$ and $g$ is a function provided they agree on the intersection of their domains: i.e., provided that for any $x$, $y$ and $z$, if $(x, y) \in f$ and $(x, z) \in g$, then $y = z$.

$\endgroup$
1
  • 1
    $\begingroup$ +1; and worth adding that this is not infrequently used in practice. It often shows up, for instance, in proofs using Zorn’s Lemma to construct a function with some property — e.g. for proving the Axiom of Choice or the Hahn–Banach Theorem from Zorn’s Lemma. In such arguments, you typically show that a certain poset of functions is closed under unions of chains — so you’re taking the union of a large set of functions, under an assumption which guarantees the necessary compatibility condition. $\endgroup$ Commented Feb 20 at 18:29
6
$\begingroup$

What you're doing is ok only if the functions have disjoint domains (or they happen to be equal on any domain overlap). This is not a very typical situation. In practice, any two functions you might want to combine would instead either have overlapping (possibly identical) domains, or structurally completely different domains.

Example of the former, $$\begin{align} f &: \mathbb{R} \to \mathbb{R}, & f(x) &= x^2 \\ g &: \mathbb{R}\setminus\{0\} \to \mathbb{R}, & g(x) &= \tfrac1x \end{align}$$ then $f\cup g$ is not a function, because it contains e.g. both $(2,4)$ and $(2,\tfrac12)$.

Example of the latter, $$\begin{align} h &: \{0,1,2,3\} \to \mathbb{Q}, & h(x) &= \begin{cases} 1 & \text{for $x=0$} \\\tfrac12 & \text{for $x=1$} \\\tfrac25 & \text{for $x=2$} \\\tfrac37 & \text{for $x=3$} \end{cases} \\ i &: \mathbb{R}^2 \to \mathbb{R}^2, & i(x,y) &= (-y,x) \end{align}$$ In this case $h\cup i$ is a function, but it is a complete oddball with a composite domain that makes it hard to work with and codomain that makes it even harder to do anything useful with.

For these reasons, the operation "union of two functions" isn't really a thing anybody does in practice.

What's far more reasonable is the disjoint union. This is actually the coproduct in the rig category $\mathsf{Set}$. For example, $$\begin{align} f\sqcup g &: \mathbb{R}\sqcup(\mathbb{R}\setminus\{0\}) \to \mathbb{R}\sqcup\mathbb{R} \\ (f\sqcup g)(x,0) &= (f(x),0) = (x^2,0) \\ (f\sqcup g)(x,1) &= (g(x),1) = (\tfrac1x,1) \end{align}$$

$\endgroup$
9
  • 4
    $\begingroup$ It's not that unusual; it's just that we usually don't give separate names to the parts, we just define f(0) and f(n: n>0) (or whatever) and then only use the combined function $\endgroup$ Commented Feb 19 at 9:31
  • 5
    $\begingroup$ It is not true that it is "ok only if the functions have disjoint domains". The correct criterion is that the functions agree on the intersection of the domains. $\endgroup$ Commented Feb 19 at 10:02
  • $\begingroup$ @ancientmathematician fair enough, but that's even more of a happenstance. $\endgroup$ Commented Feb 19 at 10:16
  • 1
    $\begingroup$ @MateenUlhaq - for programming, this is called "pattern matching", usually found in functional programming languages, or "function overloading", usually in statically typed languages; Python doesn't have either (for the most part). Rather than having an if statement, those languages allow you to define serializer(Dict d) and serializer(Class c) separately, then one or the other will be called depending on the parameter $\endgroup$ Commented Feb 20 at 9:44
  • 1
    $\begingroup$ The “happenstance” is actually quite common in mathematical writing. Consider this definition: $$|x| = \begin{cases} x, & \text{ if $x\ge 0$} \\ -x, & \text{ if $x\le 0$}\end{cases}$$ This would not be an unusual definition. The two cases overlap, which requires the reader to check that the function is well-defined, but has the benefit of emphasizing the function's symmetry. $\endgroup$
    – MJD
    Commented Feb 20 at 18:56
1
$\begingroup$

Defining the union of 2 functions in that way is an oversimplification.

Given 2 sets $X$ and $Y$, you can define a function $f:X\to Y$ as a relation $\mathcal{R}$ between $X$ and $Y$ verifying:

$$\forall (x, y, z) \in X\times Y\times Y, x\mathcal{R}y \wedge x\mathcal{R}z \implies y = z$$

But AFAIK, even if a relation between two sets is fully defined by its graph, i.e. the subset of $X\times Y$ consisting of the elements of X related to the elements of Y, I have never seen unions nor intersections of relations.

Furthermore, when you use functions, you must ensure the unicity of the image of any element from the starting set. And the union of the graphs offers no guarantee over that point.

What is common on the other hand is to define a function on subsets: if $X_1 \subset X$ and $X2 \subset X$ and you have 2 functions

$$\begin{aligned}f_1:&X_1\to Y &f_2:&X_2\to Y\\ &x\mapsto f_1(x)&&x\mapsto f_2(x) \end{aligned}$$

you can define: $$\begin{aligned}f:&X_1\cup X_2&\to &Y\\ &x&\mapsto&f(x)\end{aligned}$$

by $f(x) = f_1(x)$ if $x \in X_1$ and $f(x)=f_2(x)$ if $x\in X_2$,

provided $X_1\cap X_2 = \phi$ or at least $\forall x \in X1\cap X_2, f_1(x) = f_2(x)$

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .