# 3 Functions

A **function** from a set \(A\) to a set \(B\) is a way of associating elements of \(A\) with unique elements of \(B\). Formally, a function is a special type of relation:

**Definition 3.1 (Function) **A function \(f\) from \(A\) to \(B\) is a binary relation on \(A\) and \(B\) (i.e., \(f\subseteq A\times B\)) such that for all \(a\in A\), there exists a *unique* \(b\in B\) such that \((a,b)\in f\). We write \(f:A\rightarrow B\) when \(f\) is a function, and if \((a,b)\in f\), then write \(f(a)=b\).

Suppose that \(A=\{1, 2, 3\}\) and \(B=\{a,b\}\). Examples of relations that are functions include:

- \(f_1=\{(1,a), (2,a), (3,b)\}\). We write \(f_1(1)=a, f_1(2)=a\), and \(f_1(3)=b\)
- \(f_2=\{(1,a), (2,a), (3,a)\}\). We write \(f_2(1)=a, f_2(2)=a\), and \(f_2(3)=a\)
- \(f_3=\{(1,a), (3,b)\}\). We write \(f_3(1)=a\) and \(f_3(3)=b\)

An example of a relation that is not a function is \(R=\{(1,a), (1,b), (3,b)\}\).

When using functions, we will often use the following terminology and notation.

**Definition 3.2 (Domain/Codomain) **Suppose \(f:A\rightarrow B\) is a function. The set \(A\) is called the **domain** of \(f\) and \(B\) is called the **codomain** of \(f\).

**Definition 3.3 (Image) **Suppose \(f:A\rightarrow B\) is a function. The image of a set \(B\subseteq A\) is the set:

\[f(B)=\{a\ |\ a=f(b) \text{ for some }b\in B\}\]

**Definition 3.4 (Inverse Image) **: Suppose that \(f:A\rightarrow B\) and that \(Y\subseteq B\). The inverse image of \(Y\) is the set

\[f^{-1}(Y)=\{x\ |\ x\in A\text{ and } f(x)\in Y\}\]

**Definition 3.5 (Range) **: Suppose that \(f:A\rightarrow B\). The range of \(f\) function is the image of its domain.

For example, suppose that \(A=\{a, b, c, d\}\) and \(f:A \rightarrow \mathbb{N}\) is the function where \(f(a)=1\), \(f(b)=1\), \(f(c)=2\) and \(f(d)=4\). Then, we have the following:

- The domain of \(f\) is \(A\)
- The codomain of \(f\) is \(\mathbb{N}\)
- The range of \(f\) is \(\{1, 2\}\)
- The image of \(\{a, b\}\) is \(f(\{a, b\})= \{1\}\)
- The inverse image of \(\{2, 4\}\) is \(f^{-1}(\{2,4\})=\{c, d\}\)

**Example 3.1 **In rational choice theory, we will often consider functions with domain and/or codomains that are powersets of a set. For example, suppose that \(X=\{a, b, c\}\). A function from non-empty subsets of \(X\) to non-empty subsets of \(X\) is denoted \(f:(\wp(X)\setminus\emptyset) \rightarrow (\wp(X)\setminus\emptyset)\). An example of such a function is:

\[\begin{align*} f(\{a\}) &= \{b\}\\ f(\{b\}) &= \{b\}\\ f(\{c\}) &= \{c\}\\ f(\{a,b\}) &= \{a\}\\ f(\{a,c\}) &= \{b\}\\ f(\{b,c\}) &= \{b\}\\ f(\{a,b,c\}) &= \{b,c\}\\ \end{align*}\]

In many situation, we will need to apply one function to the output of another function. More formally, when the codomain of a function is the same as the domain of another function, then the functions can be composed to form a new function:

**Definition 3.6 (Composition of functions) **Suppose that \(f: A\rightarrow B\) and \(g: B\rightarrow C\). The composition of \(f\) with \(g\) is the function \((g\circ f):A\rightarrow C\) defined as follows: for all \(a\in A\), \(g\circ f(a) = g(f(a))\)

For example if suppose that \(A=\{a, b, c, d\}\) and \(f:A \rightarrow \mathbb{N}\) is the function where \(f(a)=1\), \(f(b)=1\), \(f(c)=2\) and \(f(d)=4\), and \(g\) is the function \(g:\mathbb{N}\rightarrow\mathbb{N}\) where for all \(n\in\mathbb{N}\), \(g(n)=2n+1\). Then \((g\circ f):A\rightarrow \mathbb{N}\) is the function where:

- \((g\circ f)(a) = g(f(a))=g(1) = 3\),
- \((g\circ f)(b) = g(f(b))=g(1) = 3\),
- \((g\circ f)(c) = g(f(c))=g(2) = 5\),
- \((g\circ f)(d) = g(f(d))=g(4) = 7\),

## 3.1 Examples using the function notation

In this course, we will discuss a number of different types of functions:

\(u:X \rightarrow \mathbb{R}\)

\(u\) is a function mapping elements of \(X\) to real numbers.

\(p:X \rightarrow [0, 1]\)

\(p\) is a function mapping elements of \(X\) to real numbers between \(0\) and \(1\). For instance, suppose that \(X= \{a, b, c\}\) and \(p:X\rightarrow [0, 1]\) is the function with \(p(a) = 0\), \(p(b)=0.5\), \(p(c)=0.5\).

\(p:\wp(X) \rightarrow [0, 1]\)

\(p\) is a function mapping subsets of \(X\) to real numbers between \(0\) and \(1\). For instance, suppose that \(X= \{a, b, c\}\) and \(p:\wp(X)\rightarrow [0, 1]\) is the function with \(p(\varnothing) = 0\), \(p(\{a\}) = 0\), \(p(\{b\}) = 0.5\), \(p(\{c\}) = 0.5\), \(p(\{a, b\}) = 0.5\), \(p(\{a, c\}) = 0.5\), \(p(\{b, c\}) = 1.0\), and \(p(\{a, b, c\}) = 1.0\).

## 3.2 Exercises

Suppose that \(X=\{a, b, c\}\) and \(u:X\rightarrow\mathbb{R}\) with \(u(a)=0.5\), \(u(b)=1.0\), \(u(c)=2.0\).

- Consider the function \(f:\mathbb{R}\rightarrow \mathbb{R}\) defined by \(f(x)= 2x + 5\). What is \(f\circ u\)?
- Consider the function \(f:\mathbb{R}\rightarrow \mathbb{R}\) defined by \(f(x)= x^2\). What is \(f\circ u\)?
- Consider the function \(f:\mathbb{R}\rightarrow \mathbb{R}\) defined by \(f(x)= -10x\). What is \(f\circ u\)?

Consider the function \(f\) defined in Example 3.1. Does this function satisfy the following constraint: for all \(Y\in\wp(X)-\emptyset\), \(f(Y)\subseteq Y\)? If so, explain why. If not, explain why it fails the constraint and find a function that satisfies the constraint.

Suppose that \(X=\{a, b, c\}\) and \(u:X\rightarrow\mathbb{R}\) with \(u(a)=0.5\), \(u(b)=1.0\), \(u(c)=2.0\).

Consider the function \(f:\mathbb{R}\rightarrow \mathbb{R}\) defined by \(f(x)= 2x + 5\). What is \(f\circ u\)?

- \(f\circ u(a) = f(u(a)) = f(0.5) = 2*0.5 + 5 = 6.0\)
- \(f\circ u(b) = f(u(b)) = f(1.0) = 2*1.0 + 5 = 7.0\)
- \(f\circ u(c) = f(u(c)) = f(2.0) = 2*2.0 + 5 = 9.0\)

Consider the function \(f:\mathbb{R}\rightarrow \mathbb{R}\) defined by \(f(x)= x^2\). What is \(f\circ u\)?

- \(f\circ u(a) = f(u(a)) = f(0.5) = 0.5^2 = 0.25\)
- \(f\circ u(b) = f(u(b)) = f(1.0) = 1.0^2 = 1.0\)
- \(f\circ u(c) = f(u(c)) = f(2.0) = 2.0^2 = 4.0\)

Consider the function \(f:\mathbb{R}\rightarrow \mathbb{R}\) defined by \(f(x)= -10x\). What is \(f\circ u\)?

Consider the function \(f\) defined in Example 3.1. Does this function satisfy the following constraint: for all \(Y\in\wp(X)-\emptyset\), \(f(Y)\subseteq Y\)? If so, explain why. If not, explain why it fails the constraint and find a function that satisfies the constraint.

The above function does not satisfy this constraint since, for instance, \(f(\{a\})=\{b\}\not\subseteq \{a\}\) (we also have that \(f(\{a,c\})=\{b\}\not\subseteq \{a,c\}\)). An example of a function that satisfies the above constraint is:

\[\begin{align*} f(\{a\}) &= \{a\}\\ f(\{b\}) &= \{b\}\\ f(\{c\}) &= \{c\}\\ f(\{a,b\}) &= \{a\}\\ f(\{a,c\}) &= \{c\}\\ f(\{b,c\}) &= \{b\}\\ f(\{a,b,c\}) &= \{b,c\}\\ \end{align*}\]