Content On This Page | ||
---|---|---|
Functions: Definition (as a Special Type of Relation) | Domain, Codomain, and Range of a Function | Main Features of a Function |
Functions: Definition, Domain, and Range
Functions: Definition (as a Special Type of Relation)
Functions are one of the most central concepts in mathematics. They describe how one quantity or element depends on or is determined by another. Formally, a function is defined as a particular kind of relation that adheres to specific constraints.
Recall that a relation $R$ from a non-empty set $A$ to a non-empty set $B$ is simply any subset of the Cartesian product $A \times B$. It's a collection of ordered pairs $(a, b)$ indicating that $a \in A$ is related to $b \in B$.
Definition of a Function
A relation $f$ from a non-empty set $A$ to a non-empty set $B$ is called a function (or a mapping or a map) if it satisfies the following two conditions:
-
Existence of Image for Every Element in A:
Every element in the set $A$ must be the first component of at least one ordered pair in $f$. This means that for every input element from $A$, there must be at least one corresponding output element in $B$ assigned by the function.$\forall x \in A, \exists y \in B \text{ such that } (x, y) \in f$
-
Uniqueness of Image for Every Element in A:
Each element in the set $A$ must be the first component of at most one ordered pair in $f$. This means that for every input element from $A$, there can be only one corresponding output element in $B$ assigned by the function. No input can lead to two or more different outputs.If $(x, y_1) \in f \text{ and } (x, y_2) \in f, \text{ then } y_1 = y_2$
$\textsf{[This must hold for all } x \in A, y_1, y_2 \in B\text{]}$
These two conditions together imply that for every $x \in A$, there exists exactly one $y \in B$ such that $(x, y) \in f$.
We denote a function $f$ from set $A$ to set $B$ as $f: A \to B$. This is read as "$f$ is a function from A to B".
- The set $A$ is called the domain of the function $f$. It is the set of all possible input values.
- The set $B$ is called the codomain of the function $f$. It is the set of all possible output values (the potential range of the function).
- If the function $f$ assigns an element $y \in B$ to an element $x \in A$, we write $y = f(x)$. The ordered pair $(x, y)$ belongs to the function when viewed as a relation, i.e., $(x, f(x)) \in f$.
- The element $y = f(x)$ is called the image of $x$ under $f$.
- The element $x$ is called a pre-image of $y$ under $f$. Note that a single element in B might have zero, one, or multiple pre-images in A, but each element in A has exactly one image in B.
From the perspective of ordered pairs, a relation $f \subseteq A \times B$ is a function if and only if:
- For every $x \in A$, there is at least one pair $(x, y) \in f$.
- No two distinct ordered pairs in $f$ have the same first component. If $(x, y_1) \in f$ and $(x, y_2) \in f$, then $y_1=y_2$.
Example 1. Let $A = \{p, q, r\}$, $B = \{1, 2, 3, 4\}$. Determine which of the following relations from A to B are functions.
(i) $R_1 = \{(p, 1), (q, 2), (r, 3)\}$
(ii) $R_2 = \{(p, 1), (p, 2), (q, 3), (r, 4)\}$
(iii) $R_3 = \{(p, 1), (q, 2)\}$
(iv) $R_4 = \{(p, 4), (q, 4), (r, 4)\}$
Answer:
Given: $A = \{p, q, r\}$, $B = \{1, 2, 3, 4\}$.
To Determine: Which relations are functions.
We examine each relation against the two conditions for being a function from A to B:
Condition 1: Every element in A ($p, q, r$) must be the first component of at least one pair.
Condition 2: No element in A can be the first component of more than one pair (i.e., each element in A must be the first component of exactly one pair).
- (i) $R_1 = \{(p, 1), (q, 2), (r, 3)\}$
- Condition 1: The first components are p, q, r. All elements of A are used. (Passes)
- Condition 2: p appears only once as a first component, q appears only once, r appears only once. (Passes)
Both conditions are satisfied. $\mathbf{R_1}$ is a function from A to B.
- (ii) $R_2 = \{(p, 1), (p, 2), (q, 3), (r, 4)\}$
- Condition 1: The first components are p, q, r. All elements of A are used. (Passes)
- Condition 2: The element p appears as the first component in two pairs: $(p, 1)$ and $(p, 2)$. This means p is associated with two different elements in B (1 and 2). (Fails)
Condition 2 is not satisfied. $\mathbf{R_2}$ is not a function from A to B.
- (iii) $R_3 = \{(p, 1), (q, 2)\}$
- Condition 1: The first components are p, q. The element r from set A is not a first component of any pair. (Fails)
Condition 1 is not satisfied. $\mathbf{R_3}$ is not a function from A to B.
- (iv) $R_4 = \{(p, 4), (q, 4), (r, 4)\}$
- Condition 1: The first components are p, q, r. All elements of A are used. (Passes)
- Condition 2: p appears only once, q appears only once, r appears only once. It is acceptable for different elements in A (p, q, r) to map to the same element in B (4). (Passes)
Both conditions are satisfied. $\mathbf{R_4}$ is a function from A to B.
Example 2. Let $R$ be the relation on $\mathbb{N}$ (natural numbers) defined by $R = \{(x, y) \mid x, y \in \mathbb{N} \text{ and } y = x - 2\}$. Is R a function from $\mathbb{N}$ to $\mathbb{N}$?
Answer:
Given: Relation $R = \{(x, y) \mid x, y \in \mathbb{N}, y = x - 2\}$ from $\mathbb{N}$ to $\mathbb{N}$.
To Determine: Is R a function from $\mathbb{N}$ to $\mathbb{N}$?
Solution:
We check the two conditions for a function from $\mathbb{N}$ (set A) to $\mathbb{N}$ (set B):
Condition 1: Every element in $\mathbb{N}$ must have an image in $\mathbb{N}$ under the rule $y = x - 2$.
Let's test some elements from the domain $\mathbb{N} = \{1, 2, 3, ...\}$.
- If $x = 1$, $y = 1 - 2 = -1$. Is $-1 \in \mathbb{N}$ (the codomain)? No.
- If $x = 2$, $y = 2 - 2 = 0$. Is $0 \in \mathbb{N}$? No (assuming $\mathbb{N} = \{1, 2, 3, ...\}$).
- If $x = 3$, $y = 3 - 2 = 1$. Is $1 \in \mathbb{N}$? Yes. The pair $(3, 1) \in R$.
Since elements like 1 and 2 from the domain $\mathbb{N}$ do not have images that are in the codomain $\mathbb{N}$, not every element of the domain $\mathbb{N}$ is associated with an element in the codomain $\mathbb{N}$ according to the rule $y = x - 2$.
Condition 1 is not satisfied.
Therefore, $\mathbf{R}$ is not a function from $\mathbb{N}$ to $\mathbb{N}$.
(Note: If the relation was defined from $\{3, 4, 5, ...\}$ to $\mathbb{N}$, or from $\mathbb{Z}$ to $\mathbb{Z}$, it would be a function. The domain and codomain are crucial).
Domain, Codomain, and Range of a Function
For a function $f: A \to B$, the sets $A$ and $B$, and the set of actual output values, have specific names:
1. Domain of the Function
The domain of a function $f: A \to B$ is the set $A$ from which the function takes its input values. By definition of a function, every element in the domain must be mapped to some element in the codomain.
Notation:
The domain of $f$ is denoted by Dom$(f)$ or simply the set $A$ itself when the function is specified as $f: A \to B$.
Dom$(f) = A$
2. Codomain of the Function
The codomain of a function $f: A \to B$ is the set $B$. This set contains all the potential output values of the function. The function is defined to map elements from the domain $A$ into the codomain $B$.
It's important to note that not every element in the codomain $B$ must necessarily be an output value of the function.
3. Range of the Function
The range of a function $f: A \to B$ is the set of all actual output values that the function produces when applied to every element in the domain $A$. It is the set of all images of the elements in the domain.
Notation:
The range of $f$ is commonly denoted by Range$(f)$ or Ran$(f)$.
Set-Builder Notation:
The range is formally defined as:
Range$(f) = \{ y \in B \mid \exists x \in A \text{ such that } f(x) = y \}$
$\textsf{or simply, } \{f(x) \mid x \in A \}$
The range is always a subset of the codomain: Range$(f) \subseteq \text{Codomain}(f)$. The range is equal to the codomain if and only if the function is surjective (onto), a concept we will discuss later.
Example 3. Consider the function $f: \{1, 2, 3\} \to \{a, b, c, d\}$ defined by $f(1)=a, f(2)=b, f(3)=a$. Find the domain, codomain, and range of $f$. Represent it using an arrow diagram.
Answer:
Given: Function $f: \{1, 2, 3\} \to \{a, b, c, d\}$ defined by $f(1)=a, f(2)=b, f(3)=a$.
To Find: Domain, Codomain, and Range of $f$.
Solution:
The function is given in the form $f: A \to B$, where $A = \{1, 2, 3\}$ and $B = \{a, b, c, d\}$.
1. Domain: The domain is the set $A$, the set of input values.
Domain$(f) = \{1, 2, 3\}$
2. Codomain: The codomain is the set $B$, the set of potential output values.
Codomain$(f) = \{a, b, c, d\}$
3. Range: The range is the set of actual output values ($f(x)$ for all $x$ in the domain).
- $f(1) = a$
- $f(2) = b$
- $f(3) = a$
The set of distinct images is $\{a, b\}$.
Range$(f) = \{a, b\}$
Note that the range $\{a, b\}$ is a subset of the codomain $\{a, b, c, d\}$. The elements c and d are in the codomain but are not images of any element in the domain.
Arrow Diagram:

Example 4. Let $g: \mathbb{R} \to \mathbb{R}$ be defined by $g(x) = |x|$ (the absolute value of x). Find the domain, codomain, and range of $g$.
Answer:
Given: Function $g: \mathbb{R} \to \mathbb{R}$ defined by $g(x) = |x|$.
To Find: Domain, Codomain, and Range of $g$.
Solution:
The function is given in the form $g: A \to B$, where $A = \mathbb{R}$ (set of real numbers) and $B = \mathbb{R}$.
1. Domain: The domain is the set $A$, the set of input values. The function $|x|$ is defined for all real numbers.
Domain$(g) = \mathbb{R}$
2. Codomain: The codomain is the set $B$, the set of potential output values, which is specified as $\mathbb{R}$.
Codomain$(g) = \mathbb{R}$
3. Range: The range is the set of all actual output values $g(x) = |x|$ when $x$ is any real number.
The absolute value of any real number is always a non-negative real number. For example, $|-5| = 5$, $|0|=0$, $|3.14|=3.14$. Any non-negative real number $y \ge 0$ can be an output, because $g(y) = |y| = y$ if $y \ge 0$.
The set of all non-negative real numbers is denoted by $\mathbb{R}_{\ge 0}$ or $[0, \infty)$.
Range$(g) = \{ y \in \mathbb{R} \mid y \ge 0 \} = [0, \infty)$
$\textsf{or } \mathbb{R}_{\ge 0}$
Note that the range ($[0, \infty)$) is a subset of the codomain ($\mathbb{R}$). Negative real numbers are in the codomain but not in the range.
Main Features of a Function
Based on the definition, we can highlight the core characteristics that distinguish a function from a general relation. Understanding these features is key to identifying whether a given relationship is a function and working with function properties.
For a function $f: A \to B$, the main features are:
-
Every Element in the Domain is Mapped:
The first condition in the definition ensures that there are no "unused" elements in the domain $A$. For every $x \in A$, there exists at least one $y \in B$ such that $(x, y) \in f$. Visually in an arrow diagram, every element in set A must have at least one arrow starting from it. -
Each Element in the Domain has a Unique Image:
The second condition ensures that for every $x \in A$, there is exactly one $y \in B$ such that $(x, y) \in f$. This means a single input cannot produce multiple different outputs. Visually in an arrow diagram, no element in set A can have more than one arrow starting from it. (Combining with Feature 1, every element in A has exactly one arrow originating from it). -
Domain and Codomain are Explicitly Defined:
A function is formally defined by specifying its domain and codomain, along with the rule of association. The sets $A$ and $B$ are part of the function's definition ($f: A \to B$). -
The Range is a Subset of the Codomain:
The set of actual output values (the Range) is always contained within the set of potential output values (the Codomain). The range might be equal to the codomain, but it cannot be larger. Range$(f) \subseteq \text{Codomain}(f)$. -
Functions Imply Direction:
A function maps elements from the domain to the codomain. The rule $y = f(x)$ specifies the output $y$ determined by the input $x$. The directionality is from $A$ to $B$.
These features are summarized in the definition requiring each element in the domain to be paired with *exactly one* element in the codomain.
Vertical Line Test for Functions on $\mathbb{R}$
For relations $R \subseteq \mathbb{R} \times \mathbb{R}$ whose graph can be plotted on the Cartesian coordinate plane, the Vertical Line Test is a simple visual method to determine if the relation represents a function of $x$ (where $x$ is the input/first component and $y$ is the output/second component).
How to Perform the Test:
- Draw the graph of the relation on the Cartesian plane.
- Mentally (or actually) draw any vertical line on the graph.
- If you can draw even one vertical line that intersects the graph at more than one point, then the relation is not a function of $x$.
- If every possible vertical line intersects the graph at at most one point (meaning zero or one point), then the relation is a function of $x$.
Reasoning:
A vertical line on the Cartesian plane consists of all points $(x_0, y)$ for a fixed value of $x_0$. If a vertical line intersects a graph at two different points, say $(x_0, y_1)$ and $(x_0, y_2)$ where $y_1 \neq y_2$, it means that the input value $x_0$ is related to two different output values $y_1$ and $y_2$. This violates the "uniqueness of image" condition (Feature 2), which requires each input to have exactly one output.

Graphs that pass the vertical line test represent $y$ as a function of $x$. For example, $y = x^2$ (a parabola opening upwards) passes the test and is a function. The relation $x = y^2$ (a parabola opening sideways) fails the test and is not a function of $x$ (though $x=y^2$ is a function of $y$).
Summary for Competitive Exams
Function ($f: A \to B$): A relation from set A (Domain) to set B (Codomain) where every element in A has exactly one image in B.
- Symbolically: For every $x \in A$, there is a unique $y \in B$ such that $(x, y) \in f$.
- Represented as ordered pairs $(x, f(x))$. No two pairs have the same first element.
Domain: The set $A$. All inputs must be from A.
Codomain: The set $B$. All outputs must be in B.
Range: The set of actual output values $\{f(x) \mid x \in A\}$. Range $\subseteq$ Codomain.
Identifying Functions:
- Roster Form: Check if every element of the starting set appears exactly once as a first component.
- Arrow Diagram: Check if every element in the domain oval has exactly one arrow originating from it.
- Graphical Form (on $\mathbb{R} \times \mathbb{R}$): Vertical Line Test - any vertical line intersects the graph at most once.