Formal Definition of a Function

The informal idea of a function as a "rule" is intuitive but imprecise. This section gives the rigorous, set-theoretic definition of a function based on ordered pairs, removing all ambiguity and providing a foundation for advanced mathematics.

Quick Reference

Concept Formal Meaning
Ordered pair $(a, b)$ where $a$ is the first member and $b$ is the second
Function $f$ A set of ordered pairs $(x, y)$ with no two pairs sharing the same first member
Domain Set of all first members of pairs in $f$
Range Set of all second members of pairs in $f$
Function notation $y = f(x)$ means the pair $(x, y)$ belongs to $f$

Why a Formal Definition?

Previously, we described a function as a "rule" or "procedure" that assigns to each element of a set $A$ exactly one element in a set $B$. However, the words rule, procedure, and assigns are not mathematical concepts: they can mean different things to different people. To make the definition completely precise, we reformulate it using the mathematical concept of an ordered pair.

Ordered Pairs

An ordered pair $(a, b)$ consists of two objects, where $a$ is the first member and $b$ is the second. Two ordered pairs $(a, b)$ and $(c, d)$ are equal if and only if both members match:

$ (a, b) = (c, d) \quad \Leftrightarrow \quad a = c \text{ and } b = d. $

You have already seen ordered pairs in coordinate geometry: the point $(3, -4)$ is different from the point $(-4, 3)$. In an ordered pair, order matters.

Definition of a Function

A function $f$ is a set of ordered pairs $(x, y)$ in which no two pairs share the same first member.

The set of all elements $x$ that appear as first members of pairs in $f$ is called the domain of $f$. The set of all second members $y$ is called the range (or set of values) of $f$.

Think of a function as a two-column table: the left column holds $x$-values (the domain), the right column holds the corresponding $y$-values (the range). The key rule is that no two rows can have the same $x$-value with different $y$-values. In set notation:

$ \text{for every } (x, y) \in f \text{ and } (x, z) \in f \quad \Rightarrow \quad y = z. $

Let

$f = \{(2,-1),\, (1,7),\, (3,5),\, (5,-1)\}.$
Solution $f$ is a function because no two pairs share the same first element. The domain and range are: $ \begin{aligned} \operatorname{Dom}(f) &= \{2, 1, 3, 5\}, \\ \operatorname{Rng}(f) &= \{-1, 7, 5\}. \end{aligned} $ Notice that the pairs $(2, -1)$ and $(5, -1)$ share the same second element $-1$. That is perfectly fine: different inputs may produce the same output. What is forbidden is the same input producing two different outputs. Now consider $g = \{(2,-1),\, (2,0),\, (1,7),\, (3,5),\, (5,8)\}.$ $g$ is not a function because both $(2, -1)$ and $(2, 0)$ belong to $g$: the input $2$ is mapped to two different outputs $-1$ and $0$.

Function Notation Revisited

Since for every $x$ in the domain there is precisely one $y$ with $(x, y) \in f$, once $x$ is specified, $y$ is uniquely determined. This justifies the familiar notation

$y = f(x),$

which simply means "the pair $(x, y)$ belongs to the set $f$." The notation is more efficient and readable than writing $(x, y) \in f$ every time.

Domain, Range, and Codomain

When we write $f : A \to B$, we declare:

  • $A$ is the domain of $f$: the set of allowable inputs.
  • $B$ is the codomain of $f$: the set that outputs are supposed to lie in.
  • The range of $f$ is the set of outputs actually produced: $\operatorname{Rng}(f) = \{f(x) \mid x \in A\}$, which is always a subset of $B$.

The range may be strictly smaller than the codomain. For example, $f : \mathbb{R} \to \mathbb{R}$ defined by $f(x) = x^2$ has codomain $\mathbb{R}$ but range $[0, \infty)$.

In the next section, we will study domain and range of a function in more detail and various examples.

Frequently Asked Questions

Why define a function as a set of ordered pairs instead of a rule? Defining a function as a set of ordered pairs is precise and unambiguous. The word "rule" is informal: two different-looking rules (e.g., $f(x) = x + 2$ and $g(x) = \frac{x^2 - 4}{x - 2}$ for $x \neq 2$) might define the same or different functions depending on their domains. The ordered-pair definition settles such questions immediately.

Is the pair $(2, 5)$ in the same function as $(5, 2)$? There is no contradiction: a function can contain both $(2, 5)$ and $(5, 2)$ as long as those are the only pairs with first members 2 and 5, respectively. The function that contains both pairs would satisfy $f(2) = 5$ and $f(5) = 2$.

Can the range equal the codomain? Yes. When the range equals the codomain, the function is called surjective (or onto). For example, $f : \mathbb{R} \to \mathbb{R}$, $f(x) = x^3$ has range $\mathbb{R}$, which equals its codomain.

Is a function the same as a relation? A relation from $A$ to $B$ is any set of ordered pairs with first members in $A$ and second members in $B$. A function is a special kind of relation where no two pairs share the same first member. Every function is a relation, but not every relation is a function.