# 1.2: Functions

- Page ID
- 49093

Let \(X\) and \(Y\) be sets. A *function from *\(X\) *into *\(Y\) is a sub set \(f \subset X \times Y\) with the following properties

- For all \(x \in X\) there is \(y \in Y\) such that \((x, y) \in f\).
- If \((x, y) \in f\) and \((x, z) \in f\), then \(y=z\).

The set \(X\) is called the *domain *of \(f\), the set \(Y\) is called the *codomain* of \(f\), and we write \(f: X \rightarrow Y\). The *range *of \(f\) is the subset of \(Y\) defined by \(\{y \in Y: \text{ there is } x \in X \text{ such that } (x, y) \in f\)\}\).

It follows from the definition that, for each \(x \in X\), there is exactly one element \(y \in Y\) such that \((x, y) \in f\). We will write \(y=f(x)\). If \(x \in X\), the element \(f(x)\) is called the *value of * \(f\) *at *\(x\) or the *image of *\(x\) *under *\(f\).

Note that, in this definition, a function is a collection of ordered pairs and, thus, corresponds to the geometric interpretation of the graph of a function given in calculus. In fact, we will refer indistinctly to the function \(f\) or to the graph of \(f\). Both refer to the set \(\{(x, f(x)): x \in X\}\).

Let \(f: X \rightarrow Y\) and \(g: X \rightarrow Y\) be two functions. Then the two functions are *equal* if they are equal as subsets of \(X \times Y\). It is easy to see that \(f\) equals \(g\) if and only if \(f(x)=g(x)\) for all \(x \in X\).

It follows from the definition that two equal functions must have the same domain.

Let \(f: X \rightarrow Y\) be a function and let \(A\) be a subset of \(X\). The *restriction** of *\(f\) *on *\(A\), denoted by \(f_{\mid A}\), is a new function from \(A\) into \(Y\) given by \( f_{\mid A}(a)=f(a)\) for all \(a \in A\).

A function \(f: X \rightarrow Y\) is called **surjective **(or is said to map \(X\) *onto *\(Y\)) if for every element \(y \in Y\), there exists an element \(x \in X\) such that \(f(x)=y\).

The function \(f\) is called *injective* (or *one-to-one*) if for each pair of distinct elements of \(X\), their images under \(f\) are also distinct. Thus, \(f\) is one-to-one if and only if for all \(x\) and \(x^{\prime}\) in \(X\), the following implication holds:

\[\left[f(x)=f\left(x^{\prime}\right)\right] \Rightarrow\left[x=x^{\prime}\right].\]

If \(f\) is both surjective and injective, it is called *bijective* or a *one-to-one correspondence*. In this case, for any \(y \in Y\), there exists a unique element \(x \in X\) such that \(f(x)=y\). This element \(x\) is then denoted by \(f^{-1}(y)\). In this way, we already built a function from \(Y\) to \(X\) called the *inverse* of \(f\).

Let \(f: X \rightarrow Y\). If there are two functions \(g: Y \rightarrow X\) and \(h: Y \rightarrow X\) such that \(g(f(x))=x\) for every \(x \in X\) and \(f(h(y))=y\) for every \(y \in Y\), then \(f\) is bijective and \(g=h=f^{-1}\).

**Proof**-
First we prove that \(f\) is surjective. Let \(y \in Y\) and set \(x=h(y)\). Then, from the assumption on \(h\), we have \(f(x)=f(h(y))=y\). This shows that \(f\) is surjective.

Next we prove that \(f\) is injective. \(x, x^{\prime} \in X\) be such that \(f(x)=f\left(x^{\prime}\right)). Then \(x=g(f(x))=g(f(x^{\prime}))=x^{\prime}\). Thus, \(f\) is injective.

We have shown that for each \(y \in Y\), there is a unique \(x \in X\), which we denote \(f^{-1}(y)\) such that \(f(x)=y\). Since for such a \(y\), \(g(y)=g(f(x))=x\), we obtain \(g(y)=f^{-1}(y)\). Since \(f(h(y))=y\), we also conclude that \(h(y)=x=f^{-1}(y)\). \(\square\)

Consider the function \(f:(1,2] \rightarrow[3,4)\) given by \(f(x)=4-(x-1)^{2}\). we show that \(f\) is bijective.

**Solution**

First let \(x, y \in(1,2]\) be such that \(f(x)=f(y)\). That is, \(4-(x-1)^{2}=4-(y-1)^{2}\). Then \((x-1)^{2}=(y-1)^{2}\). Since both \(x>1\) and \(y>1\), we conclude that \(x-1=y-1\) and, so, \(x = y\). This proves \(f\) is injective.

Next let \(y \in[3,4)\). We want \(x \in(1,2]\) be such that \(f(x)=y\). Let us set up \(4-(x-1)^{2}=y\) and solve for \(x\). We get, \(x=\sqrt{4-y}+1\). Note that since \(y<4\), \(y-4\) has a square root. Also note that since \(3 \leq y<4\), we have \(1 \geq 4-y>0\) and, hence, \(2 \geq \sqrt{4-y}+1>1\). Therefore, \(x \in(1,2]\). This proves \(f\) is surjective.

Let \(f: X \rightarrow Y\) be a function and let \(A\) be a subset of \(X\). Then the *image of *\(A\) *under *\(f\) is given by

\(f(A)=\{f(a): a \in A\}\)

It follows from the definition that

\[f(A)=\{b \in Y: b=f(a) \text { for some } a \in A\}.\]

Moreover, \(f\) is surjective if and only if \(f(X)=Y\).

For a subset \(B\) of \(Y\), the *preimage of *\(B\)* under *\(f\) is defined by

\[f^{-1}(B)=\{x \in X: f(x) \in B\}.\]

Note that, despite the notation, the definition of preimage does not require the function to have an inverse. It does not even require the function to be injective. the examples below illustrate these concepts.

Let \(f: \mathbb{R} \rightarrow \mathbb{R}\) be given by \(f(x)=3x-1\). Let \(A=[0,2)\) and \(B=\{1,-4,5\}\).

**Solution**

Then \(f(A)=[-1,5)\) and \(f^{-1}(B)=\left\{\frac{2}{3},-1,2\right\}\)

Let \(f: \mathbb{R} \rightarrow \mathbb{R}\) be given by \(f(x)=-x+7\). Let \(A=[0,2)\) and \(B=(-\infty, 3]\).

**Solution**

Then \(f(A)=(5,7]\) and \(f^{-1}(B)=[4, \infty)\).

Let \(f: \mathbb{R} \rightarrow \mathbb{R}\) be given by \(f(x)=x^{2}\). Let \(A=(-1,2)\) and \(B=[1,4)\)

**Solution**

Then \(f(A)=[0,4)\) and \(f^{-1}(B)=(-2,-1] \cup[1,2)\).

Let \(f: X \rightarrow Y\) be a function, let \(A\) be a subset of \(X\), and let \(B\) be a subset of \(Y\). The following hold:

- \(A \subset f^{-1}(f(A))\).
- \(f\left(f^{-1}(B)\right) \subset B\).

**Proof**-
We prove (a) and leave (b) as an exercise.

(a) Let \(x \in A\). By the definition of image, \(f(x) \in f(A)\). Now, by the definition of preimage, \(x \in f^{-1}(f(A))\). \(\square\)

Let \(f: X \rightarrow Y\) be a function, let \(A, B \subset X\), and let \(C, D \subset Y\). The following hold:

- If \(C \subset D\), then \(f^{-1}(C) \subset f^{-1}(D)\);
- \(f^{-1}(D \backslash C)=f^{-1}(D) \backslash f^{-1}(C)\);
- If \(A \subset B\), then \(f(A) \subset f(B)\);
- \(f(A \backslash B) \supset f(A) \backslash f(B)\).

**Proof**-
We prove (b) and leave the other parts as an exercise.

(b) We prove first that \(f^{-1}(D \backslash C) \subset f^{-1}(D) \backslash f^{-1}(C)\). Let \(x \in f^{-1}(D \backslash C)\). Then, from the definition of inverse image, we get \(f(x) \in D \backslash C\). Thus, \(f(x) \in D\) and \(f(x) \notin C\). Hence \(x \in f^{-1}(D)\) and \(x \notin f^{-1}(C)\). We conclude that \(x \in f^{-1}(D) \backslash f^{-1}(C)\).

Next we prove \(f^{-1}(D) \backslash f^{-1}(C) \subset f^{-1}(D \backslash C)\). Let \(x \in f^{-1}(D) \backslash f^{-1}(C)\). Thus, \(x \in f^{-1}(D)\) and \(x \notin f^{-1}(C)\). Therefore, \(f(x) \in D\) and \(f(x) \notin C\). This means \(f(x) \in D \backslash C\) and, so, \(x \in f^{-1}(D \backslash C)\). \(\square\)

Let \(f: X \rightarrow Y\) be a function, let \(\left\{A_{\alpha}\right\}_{\alpha \in I}\) be an indexed family of subsets of \(X\), and let \(\left\{B_{\beta}\right\}_{\beta \in J}\) be an indexed family of subsets of \(Y\). The following hold:

- \(f\left(\bigcup_{\alpha \in I} A_{\alpha}\right)=\bigcup_{\alpha \in I} f\left(A_{\alpha}\right)\);
- \(f\left(\bigcap_{\alpha \in I} A_{\alpha}\right) \subset \bigcap_{\alpha \in I} f\left(A_{\alpha}\right)\);
- \(f^{-1}\left(\bigcup_{\beta \in J} B_{\beta}\right)=\bigcup_{\beta \in J} f^{-1}\left(B_{\beta}\right)\);
- \(f^{-1}\left(\bigcap_{\beta \in J} B_{\beta}\right)=\bigcap_{\beta \in J} f^{-1}\left(B_{\beta}\right)\)

**Proof**-
We prove (a) and leave the other parts as an exercise.

(a) Let \(y \in f\left(\bigcup_{\alpha \in I} A_{\alpha}\right)\). From the definition of image of a set, there is \(x \in \bigcup_{\alpha \in I} A_{\alpha}\) such that \(y=f(x)\). From the definition of union of a family of sets, there is \(\alpha_{0} \in I\) such that \(x \in A_{\alpha_{0}}\). Therefore, \(y=f(x) \in f\left(A_{\alpha_{0}}\right)\) and, so, \(y \in \bigcup_{\alpha \in I} f\left(A_{\alpha}\right)\). \(\square\).

Give functions \(f: X \rightarrow Y\) and \(g: Y \rightarrow Z\), we define the composition function \(g \circ f\) of \(f\) and \(g\) as the function \(g \circ f: X \rightarrow Z\) given by

\[(g \circ f)(x)=g(f(x)) \text { for all } x \in X.\]

Let \(f: X \rightarrow Y\) and \(g: Y \rightarrow Z\) be two functions and let \(B \subset Z\). The following hold:

- \((g \circ f)^{-1}(B)=f^{-1}\left(g^{-1}(B)\right)\);
- If \(f\) and \(g\) are injective, then \(g \circ f\) is injective;
- If \(f\) and \(g\) are surjective, then \(g \circ f\) is surjective;
- If \(g \circ f\) is injective, then \(f\) is injective;
- If \(g \circ f\) is surjective, then \(g\) is surjective.

**Proof**-
We prove (d) and leave the other parts as an exercise.

(d) Suppose \(g \circ f\) is injective and let \(x, x^{\prime} \in X\) be such that \(f(x)=f\left(x^{\prime}\right)\). Then \((g \circ f)(x)=g(f(x))=g\left(f\left(x^{\prime}\right)\right)=(g \circ f)\left(x^{\prime}\right)\). Since \(g \circ f\) is injective, it follows that \(x=x^{\prime}\). We conclude that \(f\) is injective. \(\square\)

A *sequence *of elements of a set \(A\) is a function with domain \(\mathbb{N}\) and codomain \(A\). We discuss sequences in detail in Chapter 2.

We say that set \(A\) is *finite* if it is empty or if there exists a natural number *n *and a one-to-one correspondence \(f: A \rightarrow\{1,2, \ldots, n\}\). A set is *infinite* if it is not finite.

We leave it as an exercise to prove that the union of two finite sets is finite. It is also easy to show, by contradiction, that \(\mathbb{N}\) is infinite. The following result will be useful when studying sequences and accumulation points.

Suppose \(A\) is an infinite set. Then there exists a one-to-one function \(f: \mathbb{N} \rightarrow A\).

**Proof**-
Let \(A\) be an infinite set. We define \(f\) as follows. Choose any element \(a_{1} \in A\) and set \(f(1)=a_{1}\). Now the set \(A \backslash\left\{a_{1}\right\}\) is again infinite (otherwise \(A=\{a\} \cup\left(A \backslash\left\{a_{1}\right\}\right.\)) would be the union of two finite sets). So we may choose \(a_{2} \in A\) with \(a_{2} \neq a_{1}\) and we define \(f(2)=a_{2}\)

^{2}. Having defined \(f(1), \ldots, f(k)\), we choose \(a_{k+1} \in A\) such that \(a_{k+1} \in A \backslash\left\{a_{1}, \ldots, a_{k}\right\}\) and define \(f(k+1)=a_{k+1}\) (such an \(a_{k+1}\) exists because \(A \backslash\left\{a_{1}, \ldots, a_{k}\right\}\) is infinite and, so, nonempty). The function \(f\) so defined clearly has the desired properties. \(\square\)

To paraphrase, the previous theorem says that in every infinite set we can find a sequence made up of all distinct points.

Exercise \(\PageIndex{1}\)

Let \(f: X \rightarrow Y\) be a function. Prove that:

- If \(f\) is one-to-one, then \(A=f^{-1}(f(A))\) for every subset \(A\) of \(X\).
- If \(f\) is onto, then \(f\left(f^{-1}(B)\right)=B\) for every subset \(B\) of \(Y\).

**Answer**-
Add texts here. Do not delete this text first.

Exercise \(\PageIndex{2}\)

Let \(f: \mathbb{R} \rightarrow \mathbb{R}\) be given by \(f(x)=x^{2}-3\) and let \(A=[-2,1)\) and \(B=(-1,6)\). Find \(f(A)\) and \(f^{-1}(B)\)

**Answer**-
Add texts here. Do not delete this text first.

Exercise \(\PageIndex{3}\)

Prove that each of the following functions is bijective.

- \(f:(-\infty, 3] \rightarrow[-2, \infty)\) given by \(f(x)=|x-3|-2\).
- \(g:(1,2) \rightarrow(3, \infty)\) given by \(g(x)=\frac{3}{x-1}\).

**Answer**-
Add texts here. Do not delete this text first.

Exercise \(\PageIndex{4}\)

Prove that if \(f: X \rightarrow Y\) is injective, then the following hold:

- \(f(A \cap B)=f(A) \cap f(B) \text { for } A, B \subset X\).
- \(f(A \backslash B)=f(A) \backslash f(B) \text { for } A, B \subset X\).

**Answer**-
Add texts here. Do not delete this text first.

Exercise \(\PageIndex{5}\)

Prove part (2) of Theorem 1.2.3.

**Answer**-
Add texts here. Do not delete this text first.

Exercise \(\PageIndex{6}\)

Prove parts (1), (3), and (4) of Theorem 1.2.4.

**Answer**-
Add texts here. Do not delete this text first.

Exercise \(\PageIndex{7}\)

Prove parts (2), (3), and (4) of Theorem 1.2.5.

**Answer**-
Add texts here. Do not delete this text first.

Exercise \(\PageIndex{8}\)

Prove parts (1), (2), (3), and (5) of Theorem 1.2.6.

**Answer**-
Add texts here. Do not delete this text first.

Exercise \(\PageIndex{9}\)

Prove that the union of two finite sets is finite. *Hint**: *it is easier to show when the sets are disjoint.

**Answer**-
Add texts here. Do not delete this text first.

^{2} This fact relies on a basic axiom of set theory called the Axiom of Choice. See [Lay13] for more details.