Difference between Relation and Function
Last Updated :
16 Jan, 2025
A relation in mathematics is simply a connection or a rule that links one set of things (called the domain) to another set of things (called the range). You can think of it as a collection of pairs that shows how items from one group are connected to items in another group.
For example, Imagine you have a list of students and their favourite subjects.
- Student A → Math
- Student B → Science
- Student A → English
Here, the relation connects students (from the domain) to their favourite subjects (from the range).
A function in mathematics is a special type of relation where each input (from the domain) is connected to exactly one output (from the range). In simple terms, a function makes sure that one thing in the first group is linked to only one thing in the second group.
For example, Imagine you have a vending machine.
- You press Button A → It gives you chips.
- You press Button B → It gives you chocolate.
Here, each button (input) is connected to only one snack (output). You won't press Button A and get both chips and soda—just chips.
The difference between relation and function is given below:
Aspect | Relation | Function |
---|
Definition | A relation is a set of ordered pairs, where each pair consists of two elements, establishing a relationship between them. | A function is a special type of relation where each input value (domain) is associated with exactly unique one output value (range). |
---|
Input-Output Mapping | A single input can be related to multiple outputs. | Each input is associated with only one output. |
---|
Relationship | The relationship between elements doesn't guarantee a unique output for each input. | Every input has a precisely defined output. |
---|
Vertical Line Test | Fails the vertical line test if a vertical line intersects the graph in more than one point. | Passes the vertical line test as the graph intersects the vertical line at only one point. |
---|
Representation | Can be represented as a set of ordered pairs, table, or graph. | Represented similarly but adheres to the "unique output" rule. |
---|
General Notation | Often denoted as R, where R ⊆ A × B, with A and B being sets | Denoted as f: A → B, where f is the function, A is the domain, and B is the range. |
---|
Examples | If R = {(1, 2), (2, 3), (3, 4)}, it represents a relation between elements where each element is related to the next one. | If f(x) = x2, it represents a function where each input x is associated with its square as the output. |
---|
Real-world Example | A person and their phone numbers (one person can have multiple numbers). | A student and their unique roll number (one student has exactly one roll number). |
---|
Also Read,
Solved Examples on Relation and Function
Question 1: Given the set A = {1, 2, 3, 4} and set B = {a, b, c}, define a relation from set A to set B where each element of set A is related to each element of set B.
Solution:
To define a relation from set A to set B, we can create a relation where each element of set A is related to each element of set B. This is essentially a Cartesian product of A and B. So, the relation R can be defined as follows:
R = {(1, a), (1, b), (1, c), (2, a), (2, b), (2, c), (3, a), (3, b), (3, c), (4, a), (4, b), (4, c)}
Question 2: Let f: ℝ → ℝ be defined as f(x) = x^2 + 1. Determine whether the function f is injective, surjective, or bijective.
Solution:
To determine if f is injective, we need to check if every element in the co-domain has at most one pre-image. To check if f is surjective, we need to verify if every element in the co-domain has at least one pre-image. Finally, if f is both injective and surjective, it's bijective.
- Injective (One-to-One): Assume f(x₁) = f(x₂) for some x₁, x₂ in the domain. f(x₁) = x₁² + 1 and f(x₂) = x₂² + 1. If x₁ ≠ x₂, then f(x₁) ≠ f(x₂), as squaring a real number always results in a non-negative value and adding 1 makes it strictly greater. So, f is not injective.
- Surjective (Onto): To check if f is surjective, we need to verify if for every y in the co-domain, there exists an x in the domain such that f(x) = y. Let's take y = 0. Solving x² + 1 = 0 does not yield any real solutions. Hence, f is not surjective.
Question 3: Given the set A = {1, 2, 3} and set B = {x, y, z}, define a relation from set A to set B where each element of set A is related to exactly one element of set B.
Solution:
To define a relation from set A to set B where each element of set A is related to exactly one element of set B, we can simply pair each element of A with an element of B in a one-to-one manner. So, the relation R can be defined as follows:
R = {(1, x), (2, y), (3, z)}
Question 4: Let g: ℝ → ℝ be defined as g(x) = 2x - 3. Determine whether the function g is injective, surjective, or bijective.
Solution:
- Injective (One-to-One): Assume g(x₁) = g(x₂) for some x₁, x₂ in the domain. 2x₁ - 3 = 2x₂ - 3 2x₁ = 2x₂ Dividing by 2, x₁ = x₂. Since every element in the co-domain has at most one pre-image, g is injective.
- Surjective (Onto): To check if g is surjective, we need to verify if for every y in the co-domain, there exists an x in the domain such that g(x) = y. Let's take any y in ℝ, say y = 0. Solving 2x - 3 = 0, we get x = 3/2. So, g(3/2) = 0. Since for any y in ℝ, there exists x = 3/2 such that g(x) = y, g is surjective.
Since g is both injective and surjective, it's bijective.
Similar Reads
Swift - Difference Between Function and Method
Some folks use function and method interchangeably and they think function and method are the same in swift. But, function and method both are different things and both have their advantages. In the code, Both function and method can be used again but methods are one of these: classes, structs, and
4 min read
C++ - Difference Between Functors and Functions
In C++, we have multiple options to operate over the data like in the case where we can use functions and functors. Although both seem to be similar in a few ways but have multiple differences between them. Let's check the differences between functions and functors in C++. What are functions? Functi
3 min read
Difference between Methods and Functions in JavaScript
Grasping the difference between methods and functions in JavaScript is essential for developers at all levels. While both are fundamental to writing effective code, they serve different purposes and are used in various contexts. This article breaks down the key distinctions between methods and funct
3 min read
Difference between Relational model and Document Model
The relational model organizes data into tables with rows and columns, ideal for structured data. On the other hand, the document model stores data in hierarchical documents, which offers more flexibility for managing unstructured or semi-structured data. Both models serve different purposes in data
3 min read
Difference between identifying and non-identifying relationships
In this article, we will discuss the overview of an entity and identifying and non-identifying relationships and finally will focus on differences between both of them. Let's discuss it one by one. Overview : Entity types that do not have their own key attributes are known as the weak entity type. U
7 min read
Difference between Normal def defined function and Lambda
In this article, we will discuss the difference between normal 'def' defined function and 'lambda' function in Python. Def keywordâââââââIn Python, functions defined using def keyword are commonly used due to their simplicity. Unlike lambda functions, which always return a value, def functions do no
2 min read
Semantic Difference between Set and Type
The concepts of sets and types are fundamental in mathematics and computer science, but they serve different purposes and have distinct properties. Understanding the semantic differences between them helps clarify their roles in various theoretical and practical applications. These two terms are vit
9 min read
What is the difference between â(â¦);â and â{â¦}â in ReactJS ?
When you write JavaScript, you can use either the "(â¦)" or "{â¦}" pattern to define objects. In ReactJS, (...); and {...} are used in different contexts and have different purposes, and are used to denote different types of code structures. What is "(â¦);" in React JS ?In ReactJS, (...); is used to de
5 min read
Difference between E-R Model and Relational Model in DBMS
In database management systems (DBMS), two key methods are the Relational model and the Entity-Relationship (E-R) model. Each has a specific function in the development and operation of databases. While the Relational model provides the practical structure for organizing and managing data in relatio
4 min read
Difference between Goods and Services
Goods and Services play a crucial role in an economy. Consumer purchases many products in the form of goods and services to fulfil their requirements. Goods are tangible in nature as they can be physically touched or seen; however, services are intangible in nature. Both goods and services aim at pr
3 min read