Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Number System and Arithmetic
  • Algebra
  • Set Theory
  • Probability
  • Statistics
  • Geometry
  • Calculus
  • Logarithms
  • Mensuration
  • Matrices
  • Trigonometry
  • Mathematics
Open In App
Next Article:
Discrete Maths | Generating Functions-Introduction and Prerequisites
Next article icon

Mathematics | Total number of Possible Functions

Last Updated : 12 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we are discussing how to find a number of functions from one set to another. For understanding the basics of functions, you can refer to this: Classes (Injective, surjective, Bijective) of Functions. 

Number of functions from one set to another: Let X and Y be two sets having m and n elements respectively. In a function from X to Y, every element of X must be mapped to an element of Y. Therefore, each element of X has ‘n’ elements to be chosen from. Therefore, the total number of functions will be n×n×n.. m times = nm. 
For example: X = {a, b, c} and Y = {4, 5}. A function from X to Y can be represented in Figure 1. 
 


Considering all possibilities of mapping elements of X to elements of Y, the set of functions can be represented in Table 1. 

 

Examples: Let us discuss gate questions based on this: 

  • Q1. Let X, Y, Z be sets of sizes x, y and z respectively. Let W = X x Y. Let E be the set of all subsets of W. The number of functions from Z to E is: 
    (A) z2xy 
    (B) z x 2xy 
    (C) z2x + y 
    (D) 2xyz 

    Solution: As W = X x Y is given, number of elements in W is xy. As E is the set of all subsets of W, number of elements in E is 2xy. The number of functions from Z (set of z elements) to E (set of 2xy elements) is 2xyz. So the correct option is (D) 
     
  • Q2. Let S denote the set of all functions f: {0,1}4 → {0,1}. Denote by N the number of functions from S to the set {0,1}. The value of Log2Log2N is ______. 
    (A) 12 
    (B) 13 
    (C) 15 
    (D) 16 

    Solution: As given in the question, S denotes the set of all functions f: {0, 1}4 → {0, 1}. The number of functions from {0,1}4 (16 elements) to {0, 1} (2 elements) are 216. Therefore, S has 216 elements. Also, given, N denotes the number of function from S(216 elements) to {0, 1}(2 elements). Therefore, N has 2216 elements. Calculating required value, 

    Log2(Log2 (2216)) =Log216 = 16 

    Therefore, correct option is (D). 
     


Number of onto functions from one set to another – In onto function from X to Y, all the elements of Y must be used. In the example of functions from X = {a, b, c} to Y = {4, 5}, F1 and F2 given in Table 1 are not onto. In F1, element 5 of set Y is unused and element 4 is unused in function F2. So, total numbers of onto functions from X to Y are 6 (F3 to F8). 
 

  • If X has m elements and Y has 2 elements, the number of onto functions will be 2m-2. 

    Explanation: From a set of m elements to a set of 2 elements, the total number of functions is 2m. Out of these functions, 2 functions are not onto (If all elements are mapped to 1st element of Y or all elements are mapped to 2nd element of Y). So, number of onto functions is 2m-2.
  • If X has m elements and Y has n elements, the number if onto functions are, 
    [Tex]n^{m}-{n \choose 1}(n-1)^{m} +{ n \choose 2}(n-2)^{m}……..(-1)^{n-1}{n \choose n-1}1^{m}   [/Tex] 

Important notes:

  • The formula works only if m ≥ n.
  • If m < n, the number of onto functions is 0 as it is not possible to use all elements of Y.

Q3. The number of onto functions (surjective functions) from set X = {1, 2, 3, 4} to set Y = {a, b, c} is: 
(A) 36 
(B) 64 
(C) 81 
(D) 72 

Solution: Using m = 4 and n = 3, the number of onto functions is: 
34 – 3C1(2)4 + 3C214 = 36. 

Read More:

  • Mathematics | Total number of possible functions
  • Number of possible Functions
  • Number of Boolean functions 

Practices Problems – Total number of Possible Functions

1. Basic Function Counting

– How many functions can be defined from a set with 3 elements to a set with 2 elements?

2. Function from Set to Set

– If set A has 4 elements and set B has 3 elements, how many functions can be defined from A to B?

3. Injective Functions

– How many injective (one-to-one) functions can be defined from a set with 3 elements to a set with 5 elements?

4. Surjective Functions

– How many surjective (onto) functions can be defined from a set with 4 elements to a set with 3 elements?

5. Functions with Constraints

– If there are 4 elements in set A and 3 elements in set B, and each element in B must be the image of exactly 2 elements in A, how many such functions are possible?

6. Functions with Identical Sets

– How many functions can be defined from a set with 3 elements to itself?

7. Function Counting with Restrictions

– Consider a function from a set with 4 elements to a set with 2 elements. How many functions exist where each element of the codomain is mapped to by at least one element from the domain?

8. Bijective Functions

– How many bijective (one-to-one and onto) functions are there from a set with 3 elements to another set with 3 elements?

9. Function Counting with Specific Range

– How many functions can be defined from a set with 2 elements to a set with 4 elements if the range of the function must include exactly 2 elements?

10. Combinations and Functions

– If set A has 5 elements and set B has 4 elements, how many functions from A to B are there if exactly 3 elements of B must be used as the image of at least one element of A?


Next Article
Discrete Maths | Generating Functions-Introduction and Prerequisites

S

Sonal Tuteja
Improve
Article Tags :
  • Engineering Mathematics
  • GATE CS
  • Mathematics
  • Discrete Mathematics

Similar Reads

  • PDNF and PCNF in Discrete Mathematics
    PDNF (Principal Disjunctive Normal Form)It stands for Principal Disjunctive Normal Form. It refers to the Sum of Products, i.e., SOP. For eg. : If P, Q, and R are the variables then (P. Q'. R) + (P' . Q . R) + (P . Q . R') is an example of an expression in PDNF. Here '+' i.e. sum is the main operato
    4 min read
  • Set Theory
    Set theory is a branch of mathematics that deals with collections of objects. These collections are called sets. A set is simply a group of distinct things, like numbers, letters, or even everyday objects, that are grouped based on some common property. A set is a well-defined collection of distinct
    3 min read
  • Set Operations
    A set is simply a collection of distinct objects. These objects can be numbers, letters, or even people—anything! We denote a set using curly brackets.For example: A = {1, 2, 3} Set Operations can be defined as the operations performed on two or more sets to obtain a single set containing a combinat
    11 min read
  • Inclusion-Exclusion and its various Applications
    In the field of Combinatorics, it is a counting method used to compute the cardinality of the union set. According to basic Inclusion-Exclusion principle: For 2 finite sets [Tex]A_1 [/Tex]and [Tex]A_2 [/Tex], which are subsets of Universal set, then [Tex](A_1-A_2), (A_2-A_1) [/Tex]and [Tex](A_1\bigc
    7 min read
  • Properties of Power Set
    The power set of a set A, denoted as P(A), is the collection of all subsets of A, including: The empty set {}All single-element subsets {a}All possible combinations of elements from A, up to the entire set A itself.For example, if A={1,2}, the power set P(A) is {{},{1},{2},{1,2}}. Properties of Powe
    4 min read
  • Partial Orders and Lattices
    Partial orders and lattices are important concepts in discrete mathematics and are widely used in computer science, especially in data structures, database theory, and the theory of computation. A partial order is a binary relation that describes a set of elements that are, in a sense, ordered, but
    4 min read
  • Group in Maths: Group Theory
    Group theory is one of the most important branches of abstract algebra which is concerned with the concept of the group. A group consists of a set equipped with a binary operation that satisfies four key properties: specifically, it includes property of closure, associativity, the existence of an id
    13 min read
  • Relations in Mathematics
    Relation in Mathematics is defined as the relationship between two sets. If we are given two sets set A and set B and set A has a relation with set B then each value of set A is related to a value of set B through some unique relation. Here, set A is called the domain of the relation, and set B is c
    10 min read
  • Discrete Mathematics | Representing Relations
    Prerequisite - Introduction and types of Relations Relations are represented using ordered pairs, matrix and digraphs: Ordered Pairs - In this set of ordered pairs of x and y are used to represent relation. In this corresponding values of x and y are represented using parenthesis. Example: {(1, 1),
    2 min read
  • Representation of Relation in Graphs and Matrices
    Understanding how to represent relations in graphs and matrices is fundamental in engineering mathematics. These representations are not only crucial for theoretical understanding but also have significant practical applications in various fields of engineering, computer science, and data analysis.
    8 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences