Skip to main content
Home
Pimath

Main navigation

  • Home
User account menu
  • Log in

Breadcrumb

  1. Home

Definition of Function (Mathematics): Formulas, Properties, and Solved Exercises

Profile picture for user Pimath
By Pimath, 1 June 2025

A function is a rule between two sets, which associates to each element of the first set (the domain) a unique element of the second set (the codomain). In this post, we will analyze the formal definition of domain, codomain, the range and the main properties such as injectivity, surjectivity and bijectivity.


Contents

  • Definition of Function
  • Domain, Codomain and Range
  • Examples of Functions
  • Properties of Functions
  • Injective Functions
  • Non-Injective Functions
  • Exercises on Injective Functions
  • Surjective Functions
  • Non-Surjective Functions
  • Exercises on Surjective Functions
  • Some Examples
  • Bijective Functions
  • Inverse Function
  • Exercises on Bijective Functions
  • Restriction of a Function
  • Exercises on Function Restriction

Definition of Function

Formally, a function is a rule (or mapping) that associates to each element of a set \(X\) (called the domain) a unique element of another set \(Y\) (called the codomain). The notation used to express a function is as follows:

\[ f: X \to Y \quad , \quad x \mapsto f(x) \]

Or:

\[ \begin{align*} f \, : \, & X \longrightarrow Y \\ & x \longmapsto f(x) \end{align*} \]

In this way, we state that the function \(f\) is defined on the set \(X\) and the values it takes belong to the set \(Y\). By the term \(f(x)\) we mean the element \(y \in Y\) that is associated to each \(x \in X\), with the function \(f\) specifying the rule of correspondence between elements of \(X\) and those of \(Y\).

Domain, Codomain and Range

As mentioned previously, the domain of a function \(f\) is the set \(X\) consisting of all elements for which the function is defined. For example, the function:

\[ f \, : \, \mathbb{R} \to \mathbb{R} \quad , \quad x \mapsto \frac{1}{x^2+1} \]

is defined on the entire real line. Thus \( \text{Dom}(f) = \mathbb{R} \). The range is instead the set of values taken by the function, which in this particular case is \( \text{Range}(f) = (0, 1] \).

The codomain is the set \(Y\) that contains all values that can be reached through the function \(f\), although not all these values need to be actually obtained. The range (or image) of a function \(f\) is the set of elements of \(Y\) that are actually reached by the function, and is defined as:

\[ \text{Range}(f) = f(X) = \{ y \in Y \mid \exists x \in X \, : \, f(x) = y \} \]

Examples of Functions

A classic example of a function is the linear function, which represents a line in the Cartesian plane described by the line equation, and which can be written as:

\[ f: \mathbb{R} \to \mathbb{R} \quad , \quad f(x) = mx + q \]

where \(m\) and \(q\) are real constants. Another important example is the quadratic function, which describes a parabola and is expressed as:

\[ g: \mathbb{R} \to \mathbb{R} \quad , \quad g(x) = ax^2 + bx + c \quad , \quad a \neq 0 \]

Properties of Functions

Functions possess some fundamental properties that allow us to characterize them more precisely.

Injective Functions

A function \( f: X \to Y \) is said to be injective if distinct values correspond to distinct images. In other words, if two elements of \( X \) are distinct, their images under \( f \) are also distinct. In mathematical terms, the function is injective if:

\[ x_1 \neq x_2 \implies f(x_1) \neq f(x_2) \]

Another way to say that a function is injective is that, if two elements are mapped to the same value, they must be equal. That is:

\[ f(x_1) = f(x_2) \implies x_1 = x_2 \]

An example of an injective function is the function \( f \, : \, \mathbb{R} \to \mathbb{R} \) defined as \( f(x) = x^3 \). Let's see why this function is injective:

  • If \( x_1 \neq x_2 \), then \( x_1^3 \neq x_2^3 \), which means that the images of \( x_1 \) and \( x_2 \) are distinct.
  • In other words, for every pair of distinct values \( x_1 \) and \( x_2 \) belonging to \( \mathbb{R} \), their cubes will never be equal.

Non-Injective Functions

Not all functions are injective. A function is said to be non-injective when there exist at least two distinct elements of \( X \) that have the same image in \( Y \). In other words, there exist \( x_1 \neq x_2 \) such that \( f(x_1) = f(x_2) \).

Examples of non-injective functions include:

  • The quadratic function \( f(x) = x^2 \), which is not injective on \( \mathbb{R} \). Indeed, \( f(2) = f(-2) = 4 \), but \( 2 \neq -2 \), so \( f(x) = x^2 \) is not injective.
  • The sine function \( f(x) = \sin(x) \), which is not injective on \( \mathbb{R} \), since \( \sin(0) = \sin(\pi) = 0 \), but \( 0 \neq \pi \), so it is not injective.

Exercises on Injective Functions

Exercise 1: Determine if the function \( f(x) = 2x + 3 \) is injective.

Solution: The function is injective if, for every pair of distinct values \( x_1 \) and \( x_2 \), the images \( f(x_1) \) and \( f(x_2) \) are distinct. Suppose that \( f(x_1) = f(x_2) \), that is:

\[ 2x_1 + 3 = 2x_2 + 3 \]

Subtracting 3 from both sides we get:

\[ 2x_1 = 2x_2 \]

Dividing by 2:

\[ x_1 = x_2 \]

Since \( x_1 = x_2 \), the function is injective.

Exercise 2: Determine if the function \( f(x) = x^2 \) is injective on \( \mathbb{R} \).

Solution: The function \( f(x) = x^2 \) is not injective on \( \mathbb{R} \). Indeed, consider the values \( x_1 = -2 \) and \( x_2 = 2 \). Both satisfy \( f(x_1) = f(x_2) \), namely:

\[ (-2)^2 = 2^2 = 4 \]

But \( -2 \neq 2 \), so the function is not injective. The function is injective only if defined on \( \mathbb{R}^+ \) or \( \mathbb{R}^- \), since in these domains every number has a unique positive square.

Exercise 3: Verify if the function \( f(x) = \sin(x) \) is injective on \( \mathbb{R} \).

Solution: The function \( f(x) = \sin(x) \) is not injective on \( \mathbb{R} \), since there exist multiple values of \( x \) that give the same result. For example, \( \sin(0) = \sin(\pi) = 0 \), but \( 0 \neq \pi \). Therefore the function is not injective on \( \mathbb{R} \). If we restricted the domain of the function, for example to \( \left[ 0, \frac{\pi}{2} \right] \), the function would be injective.

Exercise 4: Determine if the function \( f(x) = \ln(x) \) is injective on the domain \( (0, \infty) \).

Solution: The function \( f(x) = \ln(x) \) is injective on the domain \( (0, \infty) \), since, if \( \ln(x_1) = \ln(x_2) \), then necessarily \( x_1 = x_2 \). This is true for all values of \( x_1 \) and \( x_2 \) belonging to the domain \( (0, \infty) \).

Exercise 5: Verify if the function \( f(x) = \displaystyle \frac{1}{x} \) is injective on \( \mathbb{R}^* \) (all reals except 0).

Solution: The function \( f(x) = \displaystyle \frac{1}{x} \) is injective on \( \mathbb{R}^* \), because if \( \displaystyle \frac{1}{x_1} = \displaystyle \frac{1}{x_2} \), then \( x_1 = x_2 \), since numbers cannot be equal unless the fractions are equal.

Surjective Functions

A function \( f: X \to Y \) is surjective if, for every \( y \in Y \), there exists at least one \( x \in X \) such that:

\[ f(x) = y \]

In other words, a function is surjective if every element of the codomain \( Y \) is the image of at least one element of \( X \).

An example of a surjective function is the function \( f: \mathbb{R} \to \mathbb{R} \), defined as \( f(x) = x^3 \). Let's see why this function is surjective:

  • For every \( y \in \mathbb{R} \), there exists an \( x \in \mathbb{R} \) such that \( x^3 = y \). For example, if \( y = 8 \), then \( x = 2 \) since \( 2^3 = 8 \).
  • In general, for every value of \( y \), there exists a value \( x \) that satisfies \( x^3 = y \), so the function is surjective.

Non-Surjective Functions

A function is said to be non-surjective if there exists at least one element \( y \in Y \) that is not the image of any element \( x \in X \). In other words, there exist values in the codomain \( Y \) that are not the image of any element in the domain \( X \).

Examples of non-surjective functions include:

  • The function \( f(x) = x^2 \) defined on \( \mathbb{R} \). The codomain of this function is \( \mathbb{R}^+ \) (the non-negative real numbers), so there are no values of \( x \) that give negative results. For example, there is no \( x \) such that \( f(x) = -1 \), so the function is not surjective on \( \mathbb{R} \).
  • The function \( f(x) = \sin(x) \), defined on \( \mathbb{R} \), has as codomain the interval \( [-1, 1] \). So, for example, there is no value of \( x \) that can give \( f(x) = 2 \), therefore the function is not surjective on \( \mathbb{R} \).

Exercises on Surjective Functions

Exercise 1: Determine if the function \( f(x) = 2x + 3 \) is surjective from \( \mathbb{R} \) to \( \mathbb{R} \).

Solution: The function is surjective if for every \( y \in \mathbb{R} \), there exists an \( x \in \mathbb{R} \) such that \( f(x) = y \). Suppose we have \( y \in \mathbb{R} \). Solving the equation \( f(x) = 2x + 3 = y \), we get:

\[ 2x = y - 3 \]

\[ x = \frac{y - 3}{2} \]

Since \( x \) exists for every \( y \in \mathbb{R} \), the function is surjective.

Exercise 2: Determine if the function \( f(x) = x^2 \) is surjective from \( \mathbb{R} \) to \( \mathbb{R} \).

Solution: The function \( f(x) = x^2 \) is not surjective from \( \mathbb{R} \) to \( \mathbb{R} \), because there are no values of \( x \) such that \( f(x) = -1 \) (since the square of a real number is always non-negative). The codomain of this function is \( \mathbb{R}^+ \), so it is not surjective on \( \mathbb{R} \).

Exercise 3: Verify if the function \( f(x) = \sin(x) \) is surjective from \( \mathbb{R} \) to \( \mathbb{R} \).

Solution: The function \( f(x) = \sin(x) \) is not surjective from \( \mathbb{R} \) to \( \mathbb{R} \), because the value of \( \sin(x) \) is bounded to the interval \( [-1, 1] \). So there are no values of \( x \) that can give \( \sin(x) = 2 \), therefore it is not surjective on \( \mathbb{R} \).

Some Examples

Exercise 4: Determine if the function \( f(x) = \ln(x) \) is surjective on \( \mathbb{R} \).

Solution: The function \( f(x) = \ln(x) \) is surjective from \( (0, \infty) \) to \( \mathbb{R} \), since for every \( y \in \mathbb{R} \), there exists an \( x \in (0, \infty) \) such that \( \ln(x) = y \). Indeed, if \( y \in \mathbb{R} \), we can find \( x = e^y \) such that \( \ln(x) = y \).

Exercise 5: Verify if the function \( f(x) = \displaystyle \frac{1}{x} \) is surjective on \( \mathbb{R}^* \) (all reals except 0) from \( \mathbb{R}^* \) to \( \mathbb{R}^* \).

Solution: The function \( f(x) = \displaystyle \frac{1}{x} \) is surjective on \( \mathbb{R}^* \), since for every \( y \in \mathbb{R}^* \), there exists an \( x \in \mathbb{R}^* \) such that \( \displaystyle \frac{1}{x} = y \). Indeed, if \( y \in \mathbb{R}^* \), we can find \( x = \displaystyle \frac{1}{y} \) such that \( f(x) = y \).

Bijective Functions

A function \( f \) is said to be bijective if it is both injective and surjective. In such case, \( f \) establishes a one-to-one correspondence between the elements of the domain and those of the codomain, and admits an inverse function:

\[ f^{-1}: Y \to X \]

Such inverse satisfies the relation:

\[ f^{-1}(y) = x \quad \text{where} \quad f(x) = y \]

The inverse function \( f^{-1} \) is defined for every \( y \in Y \), and is both a right and left inverse function, since for every \( y \in Y \) it satisfies the following identities:

\[ f(f^{-1}(y)) = y \quad \text{and} \quad f^{-1}(f(x)) = x \]

Example of Bijective Function

Consider the function \( f: \mathbb{R} \to \mathbb{R} \) defined as \( f(x) = 2x + 1 \). Let's verify that this function is bijective:

  • The function is injective: suppose that \( f(x_1) = f(x_2) \), that is \( 2x_1 + 1 = 2x_2 + 1 \). Solving, we get \( x_1 = x_2 \), so the function is injective.
  • The function is surjective: for every \( y \in \mathbb{R} \), we can solve the equation \( 2x + 1 = y \), obtaining \( x = \displaystyle \frac{y - 1}{2} \), which is a real value for every \( y \in \mathbb{R} \). Therefore, the function is surjective.
  • Since the function is both injective and surjective, it is also bijective and admits an inverse function \( f^{-1}: \mathbb{R} \to \mathbb{R} \) defined by \( f^{-1}(y) = \displaystyle \frac{y - 1}{2} \).

Inverse Function

The inverse function \( f^{-1}(y) = \displaystyle \frac{y - 1}{2} \) satisfies the following identities:

  • For every \( y \in \mathbb{R} \), \( f(f^{-1}(y)) = f\left(\frac{y - 1}{2}\right) = 2\left(\displaystyle \frac{y - 1}{2}\right) + 1 = y \), so the relation \( f(f^{-1}(y)) = y \) is satisfied.
  • For every \( x \in \mathbb{R} \), \( f^{-1}(f(x)) = f^{-1}(2x + 1) = \displaystyle \frac{(2x + 1) - 1}{2} = x \), so the relation \( f^{-1}(f(x)) = x \) is satisfied.

Example of Non-Bijective Function

Consider the function \( f(x) = x^2 \) defined on \( \mathbb{R} \). This function is not bijective, since:

  • It is not injective: for example, \( f(2) = 4 \) and \( f(-2) = 4 \), but \( 2 \neq -2 \), so the function is not injective.
  • It is not surjective: for example, there is no \( x \) such that \( f(x) = -1 \), so the function is not surjective on \( \mathbb{R} \).
  • Since it is neither injective nor surjective, it is not bijective and therefore does not admit an inverse function on \( \mathbb{R} \).

Exercises on Bijective Functions

Exercise 1: Determine if the function \( f(x) = 3x - 4 \) is bijective from \( \mathbb{R} \) to \( \mathbb{R} \). If it is bijective, write the inverse function.

Solution: The function is injective because if \( f(x_1) = f(x_2) \), that is \( 3x_1 - 4 = 3x_2 - 4 \), we get \( x_1 = x_2 \). Moreover, it is surjective because for every \( y \in \mathbb{R} \), we can solve \( 3x - 4 = y \) to get \( x = \displaystyle \frac{y + 4}{3} \). The function is therefore bijective and its inverse is \( f^{-1}(y) = \displaystyle \frac{y + 4}{3} \).

Exercise 2: Verify if the function \( f(x) = x^2 \) is bijective from \( \mathbb{R}^+ \) to \( \mathbb{R}^+ \).

Solution: The function is injective on \( \mathbb{R}^+ \) because \( x_1^2 = x_2^2 \) implies \( x_1 = x_2 \) for \( x_1, x_2 \in \mathbb{R}^+ \). It is also surjective on \( \mathbb{R}^+ \), since for every \( y \in \mathbb{R}^+ \), there exists an \( x = \sqrt{y} \) such that \( f(x) = y \). The function is therefore bijective on \( \mathbb{R}^+ \) and its inverse is \( f^{-1}(y) = \sqrt{y} \).

Exercise 3: Determine if the function \( f(x) = x^3 \) is bijective from \( \mathbb{R} \) to \( \mathbb{R} \). Write the inverse function.

Solution: The function \( f(x) = x^3 \) is both injective (since \( x_1^3 = x_2^3 \) implies \( x_1 = x_2 \)) and surjective (for every \( y \in \mathbb{R} \), there exists an \( x = \sqrt[3]{y} \) such that \( f(x) = y \)). The function is therefore bijective and its inverse is \( f^{-1}(y) = \sqrt[3]{y} \).

Additional Exercises

Exercise 4: Verify if the function \( f(x) = e^x \) is bijective from \( \mathbb{R} \) to \( (0, \infty) \).

Solution: The function \( f(x) = e^x \) is injective (since \( e^{x_1} = e^{x_2} \) implies \( x_1 = x_2 \)) and surjective on \( (0, \infty) \), since for every \( y \in (0, \infty) \), there exists an \( x = \ln(y) \) such that \( f(x) = y \). The function is therefore bijective and its inverse is \( f^{-1}(y) = \ln(y) \).

Exercise 5: Determine if the function \( f(x) = x + 2 \) is bijective from \( \mathbb{R} \) to \( \mathbb{R} \).

Solution: The function \( f(x) = x + 2 \) is bijective, since it is both injective and surjective. The inverse function is \( f^{-1}(y) = y - 2 \).

Restriction of a Function

The restriction of a function is a concept of fundamental importance, which allows us to restrict the domain of a function to a specific subset. This operation is particularly useful when we want to ensure that a function is injective and surjective, necessary conditions for invertibility. For example, consider the quadratic function \( f(x) = x^2 \), which is not injective on \( \mathbb{R} \) since for every \( y > 0 \) there exist two preimages \( x_1 = \sqrt{y} \) and \( x_2 = -\sqrt{y} \). However, by restricting the domain to \( [0, +\infty) \), we obtain an injective function, thus allowing the existence of a defined inverse function.

Example of Restriction: Quadratic Function

Consider the function \( f(x) = x^2 \) defined on \( \mathbb{R} \). This function is not injective, because there exist two distinct values \( x_1 \) and \( x_2 \) such that \( f(x_1) = f(x_2) \). For example, \( f(2) = f(-2) = 4 \). However, if we restrict the domain of \( f(x) \) to the subset \( [0, +\infty) \), the function becomes injective. Indeed, for \( x_1, x_2 \in [0, +\infty) \), the equality \( f(x_1) = f(x_2) \) implies \( x_1 = x_2 \), ensuring that the function is now injective.

The restriction of the function to \( [0, +\infty) \) makes the function injective, and we can define its inverse function:

\[ f^{-1}(y) = \sqrt{y}, \quad y \geq 0. \]

Other Examples of Restriction

The restriction of a function can be applied in various contexts to simplify the behavior of the function or to adapt it to a specific context:

  • If \( f(x) = \sin(x) \) on \( \mathbb{R} \), we can restrict the domain to \( [-\frac{\pi}{2}, \frac{\pi}{2}] \) to make it injective. In this case, the inverse function will be \( f^{-1}(y) = \arcsin(y) \), with \( y \in [-1, 1] \).
  • If \( f(x) = \tan(x) \), defined on \( \left(-\frac{\pi}{2}, \frac{\pi}{2}\right) \), the function is injective and surjective on this domain, and its inverse is \( f^{-1}(y) = \arctan(y) \).

Exercises on Function Restriction

Exercise 1: Determine if the function \( f(x) = x^3 \) is injective on \( \mathbb{R} \). Then, restrict the domain so that the function is bijective and find its inverse function.

Solution: The function \( f(x) = x^3 \) is already injective on \( \mathbb{R} \), since \( f(x_1) = f(x_2) \) implies \( x_1 = x_2 \). No restriction is necessary, and the inverse function is \( f^{-1}(y) = \sqrt[3]{y} \).

Exercise 2: The function \( f(x) = x^2 \) is not injective on \( \mathbb{R} \). Restrict the domain to an interval where the function is injective and find the inverse function.

Solution: To make the function injective, we restrict the domain to \( [0, +\infty) \). In this case, the inverse function will be \( f^{-1}(y) = \sqrt{y} \), with \( y \geq 0 \).

Exercise 3: Consider the function \( f(x) = \ln(x) \) defined on \( (0,+\infty) \). Restrict the domain to \( [1,+\infty) \) and write the inverse function.

Solution: The logarithmic function is injective and surjective on \( (0,+\infty) \) (with codomain \( \mathbb{R} \)). If we restrict the domain to \( [1,+\infty) \), the range becomes \( [0,+\infty) \) (since \( \ln(1)=0 \) and \( \ln(x) \) is strictly increasing). Consequently, the inverse function is:

\[ f^{-1}(y)=e^y, \quad y\in [0,+\infty). \]

Exercise 4: The function \( f(x) = \sin(x) \) is not injective on \( \mathbb{R} \). Restrict the domain to an interval where the function is injective and find the inverse function.

Solution: The function \( f(x) = \sin(x) \) is injective on \( [-\frac{\pi}{2}, \frac{\pi}{2}] \). The inverse function will be \( f^{-1}(y) = \arcsin(y) \), with \( y \in [-1, 1] \).

The restriction of a function allows us to manipulate the domain of a function to obtain desired properties such as injectivity, surjectivity or bijectivity.


Your feedback is important to us! Leave a comment and help us improve this content. Thank you!

Feedback

Support us with a Like:
Or, share:

Tags

  • Mathematical Analysis 1

Support us with a Like:
Or, share:

Copyright © 2025 | Pimath | All Rights Reserved