Bijective Functions
Learn about bijective functions.
We'll cover the following...
Bijective functions
If a function is both injective and surjective, it is called a bijective function— also called a one-to-one correspondence or simply a correspondence. In a bijective function, every element of the domain maps to a unique element of the codomain, and every element in the codomain has a preimage. This means a bijective function pairs up all the domain and codomain elements.
Examples
Take the following sets:
Using these sets, we define the following function:
Because the function
The illustration given below shows the
Here are a few more examples of bijective functions:
Checking if a function is bijective using Python
Let’s explore the following code to check if a given function is a bijective function. Please feel free to make changes and experiment with the given code.
Code explanation
Lines 1–22: We define a
is_functionfunction that takes three arguments, i.e.,domain,codomain, andfunction. It checks if the argumentfunctionis a valid function with thedomainand thecodomain. It returnsFalseiffunctionis not a valid function.Lines 24–32: We define a
is_injectivefunction that takes three arguments, i.e.,domain,codomain, andfunction. It checks if the passedfunctionis injective by checking if everydomainelement has a unique image. It returnsTrueif the function is injective and returnsFalseotherwise.Lines 34–41: We define a
is_surjectivefunction that takes three arguments, i.e.,domain,codomain, andfunction. It checks if the passedfunctionis surjective or not by checking if everycodomainelement has a preimage. It returnsTrueif the function is surjective and returnsFalseotherwise.Lines 43–44: We define a
is_bijectivefunction that takes three arguments, i.e.,domain,codomain, andfunction. It checks if the passedfunctionis bijective.Lines 46–50: We define the sets
domain,codomain, andf.Lines 52–59: We check if
fis a valid function from thedomainto thecodomain, and if it is, we check iffis a bijective function. We print messages according to each situation.
Types of functions
A function is always one of the four types listed below:
Neither injective nor surjective
Only injective but not surjective
Only surjective and not injective
Both injective and surjective, which means bijective
Let’s look at a few examples of functions showing each of these cases. These functions are defined using the following sets:
An example of all four types of functions is given in the following table.
| Type | Function |
|---|---|
| Neither injective nor surjective |