# Naive Set Theory: Functions

## Functions

Functions are familiar to all who passed through middle school algebra. There are polynomials, trigonometric functions, exponential and logarithmic functions - plus plenty more exotic functions. In our set theoretic world, we'd like to think of functions as little machines that convert elements from one set into those of another. This task of associating one element with another is well suited for relations.

function $f$ is a relation such that for every $x \in \text{dom}(f)$ there is only one $y \in \text{img}(f)$ such that $xfy$. More formally, a function is a relation $f$ where $xfy$ and $xfz$ implies that $y=z$. For a given ordered pair $xfy$, the element $y$ is called the value of $f$ at $x$, and is written as $f(x)$. The formula for constructing the ordered pairs is written as $f(x) = \ldots$, where we fill in the $\ldots$ with the logic we want. For example, the square root function written as $f(x) = \sqrt{x}$.

However, the $f(x) = \ldots$ leaves us with the problem of not knowing the domain of the function. The square root function is defined for all complex numbers, all positive real numbers, some rational numbers, and a relative handful of integers and natural numbers. Just writing $f(x) = \sqrt{x}$ gives us no insight into whether $\sqrt{2}$ is in the domain. Thus we introduce more notation.

A function $f$ whose domain is $A$ and whose image set is a subset of $B$ is written as $f : A \rightarrow B$. Note that the domain is exactly the set $A$, but image set is a subset of the set $B$. This spares us from having to figure out exactly what set the image set is for a given function, which can often be tricky. The superset $B$ of the image set is called the codomain of a function. The codomain is not unique, as any superset of the image set will do, but it is nice to pick one that is close to the image set.

Combining both pieces of notation gives us a clear way to express functions. First we specify the domain and codomain, then we specify the rule. For example, define a function $f : \mathbb{C} \rightarrow \mathbb{C}$ where $f(x) = \sqrt{x}$. In many contexts, the arrow notation may be omitted when the domain and codomain are clear.

## Problems

1. Consider a familiar equation from algebra: $f(x) = x^2$. Is this a sufficiently rigorous description of a function?

No, the equation $f(x) = x^2$ does not meet the definition of a function given here because while it specifies the method of creating ordered pairs, it does not specify the domain and codomain. The domain could be the integers, or the real numbers, or complex-valued square matrices, or even some more unusual mathematical object that has the "power of two" operation defined for it. The domain and range are often implied by the context, although explicitly stating them removes any ambiguity.

2. Let $A = \{a, b, c, \ldots, z\}$ be the set containing the letters of the alphabet, and let $B$ be the set $\{0, 1\}$.

1. Write out a function that maps all letters that are consonants in $A$ to $0$ in $B$ and all letters that are always vowels in $A$ to $1$ in $B$.
2. Write out all of the ordered pairs defined by the function
1. Define $f : A \rightarrow B$ such that $f(x) = \left\{ \begin{matrix} 0 & x \text{ is a consonant} \\ 1 & x \text{ is a vowel} \end{matrix}\right.$

2. $\begin{matrix} f = \\ \end{matrix} \begin{matrix} \{(a,1),(b,0),(c,0),(d,0),(e,1),(f,0),(g,0),(h,0),(i,1),(j,0), (k,0),(l,0),(m,0), \\ (n,0),(o,1),(p,0),(q,0),(r,0),(s,0),(t,0),(u,0),(v,0),(w,0),(x,0),(y,0), z,0)\} \end{matrix}$
3. Consider the "function" $f : \mathbb{R} \rightarrow \mathbb{R}$ where $f(x) = \dfrac{1}{x^2-1}$. What is wrong with this supposed function? How would you fix this error? Write out a new, properly defined function with this fix.

The domain is specified to be $\mathbb{R}$, however this includes the values $-1$ and $1$, both of which result in division by zero in the rule. The simplest solution is to exclude these values from the domain. Define the new function as $f' : \mathbb{R} \setminus \{-1, 1\} \rightarrow \mathbb{R}$ where $f(x) = \dfrac{1}{x^2-1}$.