# Different Types of Functions

On the Functions and Relations page we defined what a function and a relation from a set $X$ to a set $Y$ was. We will now look at some special terminology regarding functions as well as look at some different types of functions. We will give the standard definitions as well as set definitions of these concepts below.

Definition: Let $f : X \to Y$ be a function. The Domain of $f$ is the set $X$. The Codomain of $f$ is the set $Y$. The Range of $f$ is the set $f(X) \subseteq Y$. |

The diagram above illustrates a function that takes elements from the domain and maps them to exactly one element in the codomain. The subset of elements that are "mapped to" of the codomain is called the range. We should note that it is perfectly fine for two elements in the domain to map to the same element in the range. However, if one element in the domain maps to two elements in the range, then we no longer have a function.

We will now classify some important types of functions.

Definition: A function $f : A \to B$ is called an Injection, Injective Function, or One-to-One Function if for all $m, n \in A$ where $m \neq n$ we have that $f(m) \neq f(n)$. (Equivalently, $f : A \to B$ is an injection if for all $(m, x)$ and $(n, y)$ we have that if $m \neq n$ then $x \neq y$). |

From our definition we note that every element $x \in A$ maps to a unique element $y \in B$.

In our first example at the top of the page, there were two elements in the domain that mapped to the same element in the range. Such a function is not one-to-one. In terms of equations, a function can easily be determined to be one-to-one if it passes what is known as the **horizontal line test**. If you take any horizontal line, it should intersect the function at most one time.

Definition: A function $f :A \to B$ is called a Surjection, Surjective Function, or an Onto Function if $B = R(f)$, that is, the codomain of $f$ is equal to the range of $f$. For every $b \in B$, $b = f(a)$ for some $a \in A$. (Equivalently, $f : A \to B$ is a surjection if for every $b \in B$ there exists an $a \in A$ such that $(a, b) \in f$). |

Therefore, our definition of a surjection says that all elements x in the domain map to all elements y in the codomain at least once.

As you can see from the diagram above, there are no elements in the codomain that aren't mapped to, and hence $B = R(f)$.

Definition: A function $f$ is called a Bijection or Bijective Function if $f$ is both injective and surjective, that is, for all $m, n \in A$ where $m \neq n$ satisfies $f(m) \neq f(n)$, and $B = R(f)$, so for every $b \in B$, $b = f(a)$ for some $a \in A$. |