ScholarQuill logoScholarQuillUniversity Notes
  • Notes
  • Past Papers
  • Blogs
  • Todo
Login
ScholarQuill logoScholarQuillUniversity Notes
Login
NotesPast PapersBlogsTodo
More
SubjectsDiscussionCGPA CalculatorGPA CalculatorStudent PortalCourse Outline
About
About usPrivacy PolicyReportContact
Notes
Past Papers
Blogs
Todo
Analytics
    Current Subject
    🧩
    Discrete Structures
    CSI-303
    Progress0 / 21 topics
    Topics
    1. Introduction to Logic and Proofs2. Direct Proofs3. Proof by Contradiction4. Sets5. Combinatorics6. Sequences7. Formal Logic8. Propositional and Predicate Calculus9. Methods of Proof10. Mathematical Induction and Recursion11. Loop Invariants12. Relations and Functions13. Pigeonhole Principle14. Trees and Graphs15. Elementary Number Theory16. Optimization and Matching17. Fundamental Structures18. Functions19. Relations (Recursions)20. Cardinality and Countability21. Probabilistic Methods
    CSI-303›Functions
    Discrete StructuresTopic 18 of 21

    Functions

    13 minread
    2,214words
    Intermediatelevel

    Functions in Discrete Mathematics

    In discrete mathematics, a function is a fundamental concept used to describe the relationship between two sets, where each element from the first set is associated with exactly one element from the second set. Functions are widely used in areas such as algorithms, number theory, computer science, and graph theory.


    Definition of a Function

    A function fff from set AAA to set BBB, denoted by f:A→Bf: A \to Bf:A→B, is a rule that assigns each element a∈Aa \in Aa∈A to exactly one element b∈Bb \in Bb∈B. In other words, for every a∈Aa \in Aa∈A, there exists a unique b∈Bb \in Bb∈B such that f(a)=bf(a) = bf(a)=b.

    • Domain: The set AAA is called the domain of the function, which consists of all the possible inputs.
    • Codomain: The set BBB is called the codomain of the function, which contains all possible outputs (though not every element in the codomain has to be an output).
    • Range: The range of the function is the set of all outputs f(a)f(a)f(a) for a∈Aa \in Aa∈A. It is a subset of the codomain.

    Types of Functions

    Functions can be classified in various ways based on their properties. Some important types include:

    1. Injective Function (One-to-One)

    A function f:A→Bf: A \to Bf:A→B is injective (or one-to-one) if every element in the domain AAA maps to a distinct element in the codomain BBB. In other words, if f(a1)=f(a2)f(a_1) = f(a_2)f(a1​)=f(a2​), then a1=a2a_1 = a_2a1​=a2​.

    • Example: Let A={1,2,3}A = \{1, 2, 3\}A={1,2,3} and B={a,b,c}B = \{a, b, c\}B={a,b,c}, with the function f(1)=af(1) = af(1)=a, f(2)=bf(2) = bf(2)=b, and f(3)=cf(3) = cf(3)=c. This function is injective because each element in AAA maps to a unique element in BBB.

    2. Surjective Function (Onto)

    A function f:A→Bf: A \to Bf:A→B is surjective (or onto) if for every element b∈Bb \in Bb∈B, there exists at least one element a∈Aa \in Aa∈A such that f(a)=bf(a) = bf(a)=b. In other words, the range of the function is equal to the entire codomain.

    • Example: Let A={1,2}A = \{1, 2\}A={1,2} and B={a,b}B = \{a, b\}B={a,b}, with the function f(1)=af(1) = af(1)=a and f(2)=bf(2) = bf(2)=b. This function is surjective because every element of BBB is covered by the function.

    3. Bijective Function (One-to-One and Onto)

    A function f:A→Bf: A \to Bf:A→B is bijective if it is both injective (one-to-one) and surjective (onto). This means that each element in the domain maps to a distinct element in the codomain, and every element in the codomain is covered.

    • Example: Let A={1,2,3}A = \{1, 2, 3\}A={1,2,3} and B={a,b,c}B = \{a, b, c\}B={a,b,c}, with the function f(1)=af(1) = af(1)=a, f(2)=bf(2) = bf(2)=b, and f(3)=cf(3) = cf(3)=c. This function is bijective because it is both injective and surjective.

    Function Notation

    Function notation is a way of representing the relationship between elements of the domain and the codomain.

    • f:A→Bf: A \to Bf:A→B means that fff is a function from set AAA to set BBB.
    • f(a)=bf(a) = bf(a)=b means that the function fff maps the element aaa in the domain AAA to the element bbb in the codomain BBB.

    Operations on Functions

    There are several important operations that can be performed on functions, such as composition and inverse functions.

    1. Function Composition

    Given two functions f:A→Bf: A \to Bf:A→B and g:B→Cg: B \to Cg:B→C, the composition of fff and ggg, denoted g∘fg \circ fg∘f, is a function from AAA to CCC defined by:

    (g∘f)(a)=g(f(a))(g \circ f)(a) = g(f(a))(g∘f)(a)=g(f(a))

    In words, we first apply fff to an element a∈Aa \in Aa∈A and then apply ggg to the result.

    • Example: If f:{1,2,3}→{a,b,c}f: \{1, 2, 3\} \to \{a, b, c\}f:{1,2,3}→{a,b,c} and g:{a,b,c}→{x,y,z}g: \{a, b, c\} \to \{x, y, z\}g:{a,b,c}→{x,y,z}, with f(1)=af(1) = af(1)=a, f(2)=bf(2) = bf(2)=b, and f(3)=cf(3) = cf(3)=c, and g(a)=xg(a) = xg(a)=x, g(b)=yg(b) = yg(b)=y, and g(c)=zg(c) = zg(c)=z, then g∘f(1)=g(f(1))=g(a)=xg \circ f(1) = g(f(1)) = g(a) = xg∘f(1)=g(f(1))=g(a)=x.

    2. Inverse Function

    A function f:A→Bf: A \to Bf:A→B has an inverse function, denoted f−1:B→Af^{-1}: B \to Af−1:B→A, if and only if fff is bijective. The inverse function reverses the mapping, so for every element b∈Bb \in Bb∈B, f−1(b)=af^{-1}(b) = af−1(b)=a where f(a)=bf(a) = bf(a)=b.

    • Example: If f:A→Bf: A \to Bf:A→B is bijective, then f−1(f(a))=af^{-1}(f(a)) = af−1(f(a))=a for all a∈Aa \in Aa∈A, and f(f−1(b))=bf(f^{-1}(b)) = bf(f−1(b))=b for all b∈Bb \in Bb∈B.

    Types of Functions Based on Structure

    1. Identity Function

    The identity function IAI_AIA​ on a set AAA is a function that maps every element of AAA to itself. For all a∈Aa \in Aa∈A, IA(a)=aI_A(a) = aIA​(a)=a.

    • Example: If A={1,2,3}A = \{1, 2, 3\}A={1,2,3}, then the identity function IAI_AIA​ is IA(1)=1I_A(1) = 1IA​(1)=1, IA(2)=2I_A(2) = 2IA​(2)=2, and IA(3)=3I_A(3) = 3IA​(3)=3.

    2. Constant Function

    A constant function is a function where every element in the domain is mapped to the same element in the codomain. For all a∈Aa \in Aa∈A, f(a)=cf(a) = cf(a)=c, where ccc is a fixed element in BBB.

    • Example: If A={1,2,3}A = \{1, 2, 3\}A={1,2,3} and B={a,b}B = \{a, b\}B={a,b}, and f(1)=f(2)=f(3)=af(1) = f(2) = f(3) = af(1)=f(2)=f(3)=a, then fff is a constant function.

    3. Polynomial Function

    A polynomial function is a function that can be expressed as f(x)=anxn+an−1xn−1+⋯+a1x+a0f(x) = a_n x^n + a_{n-1} x^{n-1} + \cdots + a_1 x + a_0f(x)=an​xn+an−1​xn−1+⋯+a1​x+a0​, where an,an−1,…,a1,a0a_n, a_{n-1}, \dots, a_1, a_0an​,an−1​,…,a1​,a0​ are constants, and nnn is a non-negative integer.

    • Example: The function f(x)=3x2+2x+1f(x) = 3x^2 + 2x + 1f(x)=3x2+2x+1 is a polynomial function.

    4. Piecewise Function

    A piecewise function is a function defined by different expressions based on the input value. It is a combination of several functions, each of which applies to a specific part of the domain.

    • Example: The function f(x)f(x)f(x) defined as: f(x)={x2if x≥0−xif x<0f(x) = \begin{cases} x^2 & \text{if } x \geq 0 \\ -x & \text{if } x < 0 \end{cases}f(x)={x2−x​if x≥0if x<0​ is a piecewise function.

    Conclusion

    Functions are one of the most fundamental concepts in mathematics and computer science. They establish relationships between elements of sets and are essential for modeling and solving problems across many fields. Understanding the properties and operations of functions, such as injectivity, surjectivity, and composition, is crucial for designing algorithms, analyzing data, and understanding mathematical structures.

    Previous topic 17
    Fundamental Structures
    Next topic 19
    Relations (Recursions)

    Past Papers

    Open this section to load past papers

    Click on Show Past Papers to see past papers.
    On This Page
      Reading Stats
      Est. reading time13 min
      Word count2,214
      Code examples0
      DifficultyIntermediate