Discrete Mathematics Lecture: Functions and Relations

Fundamentals of Relations

  • A relation RR from set AA to set BB is defined as a set of ordered pairs in which elements of set AA are associated with elements of set BB.

  • Mathematically, a relation is any subset of the Cartesian product of AA and BB, denoted as R⊆A×BR \subseteq A \times B.

  • If an ordered pair (a,b)(a, b) belongs to the relation ((a,b)∈R)( (a, b) \in R ), it is said that aa is RR-related to bb, written as aRba R b.

  • If an ordered pair (a,b)(a, b) does not belong to the relation ((a,b)∉R)( (a, b) \notin R ), then aa is not RR-related to bb, written as aR̸ba \not R b.

  • The domain of a relation RR is the set of all first elements from the ordered pairs within RR.

  • The range of a relation RR is the set of all second elements from the ordered pairs within RR.

  • Example of a relation:

    • Let A={1,2,3}A = \{1, 2, 3\} and B={x,y,z}B = \{x, y, z\}.

    • A valid relation is R={(1,x),(1,z),(2,y),(3,y)}R = \{(1, x), (1, z), (2, y), (3, y)\}.

Inverse Relations

  • Let RR be any relation from set AA to set BB.

  • The inverse of RR, denoted by R−1R^{-1}, is a relation from set BB to set AA containing ordered pairs that belong to RR when reversed.

  • Formal definition: R−1={(b,a):(a,b)∈R}R^{-1} = \{(b, a) : (a, b) \in R\}.

  • Example of an inverse relation:

    • Let A={1,2,3}A = \{1, 2, 3\} and B={x,y,z}B = \{x, y, z\}.

    • If R={(1,y),(1,z),(3,y)}R = \{(1, y), (1, z), (3, y)\}, then R−1={(y,1),(z,1),(y,3)}R^{-1} = \{(y, 1), (z, 1), (y, 3)\}.

Properties and Types of Relations

  • Reflexive Relations:

    • A relation RR on a set AA is reflexive if (a,a)∈R(a, a) \in R for every element a∈Aa \in A.

    • Equivalently, aRaa R a must hold for all a∈Aa \in A.

    • Example: For A={1,2,3}A = \{1, 2, 3\}, the relation R={(1,1),(2,2),(3,3),(1,2)}R = \{(1, 1), (2, 2), (3, 3), (1, 2)\} is reflexive because every element is related to itself.

    • Note: Reflexivity depends only on whether every element is related to itself; additional pairs like (1,2)(1, 2) do not affect this property.

  • Symmetric Relations:

    • A relation RR is symmetric if whenever (a,b)∈R(a, b) \in R, then (b,a)∈R(b, a) \in R.

    • A relation is not symmetric (antisymmetric) if there exist elements a,b∈Aa, b \in A such that (a,b)∈R(a, b) \in R but (b,a)∉R(b, a) \notin R.

    • Example: R={(1,1),(2,2),(3,3),(1,2),(2,1)}R = \{(1, 1), (2, 2), (3, 3), (1, 2), (2, 1)\} is symmetric because the reverse of (1,2)(1, 2) is (2,1)(2, 1), and diagonal pairs are their own reverses.

  • Transitive Relations:

    • A relation RR on set AA is transitive if whenever (a,b)∈R(a, b) \in R and (b,c)∈R(b, c) \in R, then (a,c)∈R(a, c) \in R.

    • A relation is not transitive if there exist elements such that (a,b),(b,c)∈R(a, b), (b, c) \in R but (a,c)∉R(a, c) \notin R.

    • Example: R={(1,1),(2,2),(3,3),(1,2),(2,3),(1,3)}R = \{(1, 1), (2, 2), (3, 3), (1, 2), (2, 3), (1, 3)\} is transitive because (1,2)(1, 2) and (2,3)(2, 3) are in RR, and their chain result (1,3)(1, 3) is also in RR.

  • Equivalence Relations:

    • A relation RR on a set AA is an equivalence relation if it satisfies three conditions: it must be reflexive, symmetric, and transitive for all a,b,c∈Aa, b, c \in A.

    • Example Verification: Let A={1,2,3}A = \{1, 2, 3\} and R={(1,1),(2,2),(3,3),(1,2),(2,1)}R = \{(1, 1), (2, 2), (3, 3), (1, 2), (2, 1)\}.

      • Reflexive: (1,1),(2,2),(3,3)∈R(1, 1), (2, 2), (3, 3) \in R.

      • Symmetric: (1,2)∈R(1, 2) \in R and (2,1)∈R(2, 1) \in R.

      • Transitive: (1,2),(2,1)∈R  ⟹  (1,1)∈R(1, 2), (2, 1) \in R \implies (1, 1) \in R and (2,1),(1,2)∈R  ⟹  (2,2)∈R(2, 1), (1, 2) \in R \implies (2, 2) \in R.

Matrix Representation of Relations

  • Properties of a relation can be checked using its matrix MM:

    • Reflexive: Check if all diagonal entries mii=1m_{ii} = 1 for all ii.

    • Symmetric: Check if the matrix is equal to its transpose, M=MTM = M^T, meaning mij=mjim_{ij} = m_{ji}.

    • Transitive: Check if the square of the matrix is less than or equal to the matrix itself, M2≤MM^2 \le M.

  • Example Matrix: (101001111)\begin{pmatrix} 1 & 0 & 1 \\ 0 & 0 & 1 \\ 1 & 1 & 1 \end{pmatrix}.

Introduction to Functions

  • Definition: Let AA and BB be nonempty sets. A function from AA to BB is an assignment of exactly one element of BB to each element of AA.

  • Notation: If ff is a function from AA to BB, it is written as f:A→Bf : A \rightarrow B.

  • Terminology: Functions are also referred to as mappings or transformations.

  • Mapping Notation: For an ordered pair (a,b)(a, b) where a∈Aa \in A and b∈Bb \in B, the mapping is written as f(a)=bf(a) = b.

  • Domains and Codomains:

    • The set AA is the domain of the function.

    • The set BB is the target set or codomain.

    • If f(a)=bf(a) = b, bb is the image of aa, and aa is a preimage of bb.

    • The range of ff is the set of all images of elements of AA.

Equality of Functions

  • Two functions are considered equal if they meet three specific criteria:

    1. They share the same domain.

    2. They share the same codomain.

    3. They assign the identical output to every input within the domain.

  • Mathematically: f=gf = g if and only if f(x)=g(x)f(x) = g(x) for all x∈Ax \in A, given g:A→Bg : A \rightarrow B and f:A→Bf : A \rightarrow B.

  • Example of Equality: f(x)=(x+1)2f(x) = (x + 1)^2 and g(x)=x2+2x+1g(x) = x^2 + 2x + 1 defined on R\mathbb{R} are equal because their formulas expand to the same values for all x∈Rx \in \mathbb{R}.

  • Example of Inequality: f:R→Rf : \mathbb{R} \rightarrow \mathbb{R} with f(x)=x2f(x) = x^2 and g:[0,∞)→Rg : [0, \infty) \rightarrow \mathbb{R} with g(x)=x2g(x) = x^2. Although the formulas are the same, the domains differ (Dom(f)=R≠Dom(g)=[0,∞)Dom(f) = \mathbb{R} \neq Dom(g) = [0, \infty)), so f≠gf \neq g.

Arithmetic Operations on Functions

  • A function is real-valued if its codomain is the set of real numbers R\mathbb{R}.

  • A function is integer-valued if its codomain is the set of integers Z\mathbb{Z}.

  • Addition and multiplication of two functions (f1f_1 and f2f_2) from AA to R\mathbb{R} are defined as:

    • Sum: (f1+f2)(x)=f1(x)+f2(x)(f_1 + f_2)(x) = f_1(x) + f_2(x).

    • Product: (f1f2)(x)=f1(x)f2(x)(f_1 f_2)(x) = f_1(x) f_2(x).

  • Numerical Example:

    • If f1(x)=x2f_1(x) = x^2 and f2(x)=x−x2f_2(x) = x - x^2 from R\mathbb{R} to R\mathbb{R}, then:

    • (f1+f2)(x)=x2+(x−x2)=x(f_1 + f_2)(x) = x^2 + (x - x^2) = x.

    • (f1f2)(x)=x2(x−x2)=x3−x4(f_1 f_2)(x) = x^2(x - x^2) = x^3 - x^4.

One-to-One and Onto Functions

One-to-One (Injective) Functions
  • A function f:A→Bf : A \rightarrow B is one-to-one or injective if different elements of the domain have different images.

  • Formal Definition: ff is one-to-one if and only if f(a)=f(b)  ⟹  a=bf(a) = f(b) \implies a = b for all a,ba, b in the domain.

  • Contrapositive Definition: ff is one-to-one if a≠b  ⟹  f(a)≠f(b)a \neq b \implies f(a) \neq f(b).

  • Quantifier Notation: ∀a∀b[f(a)=f(b)  ⟹  a=b]\forall a \forall b [f(a) = f(b) \implies a = b] or ∀a∀b[a≠b  ⟹  f(a)≠f(b)]\forall a \forall b [a \neq b \implies f(a) \neq f(b)].

  • Proving injectivity: Assume f(x1)=f(x2)f(x_1) = f(x_2) and solve to show x1=x2x_1 = x_2.

    • Example: For f(x)=x3+1f(x) = x^3 + 1, assuming x13+1=x23+1x_1^3 + 1 = x_2^3 + 1 leads to x13=x23x_1^3 = x_2^3, which implies x1=x2x_1 = x_2. Thus, it is injective.

Onto (Surjective) Functions
  • A function f:A→Bf : A \rightarrow B is onto or surjective if every element of the codomain BB is the image of at least one element of AA.

  • Formal Definition: ∀b∈B,∃a∈A\forall b \in B, \exists a \in A such that f(a)=bf(a) = b.

  • Proving surjectivity: Let yy be an arbitrary element of the codomain, solve the equation f(x)=yf(x) = y for xx, and confirm that xx exists in the domain for every possible yy.

    • Example 1: Show f:R→Rf : \mathbb{R} \rightarrow \mathbb{R} such that f(x)=3x−5f(x) = 3x - 5 is onto.

      • 3x−5=y  ⟹  x=y+533x - 5 = y \implies x = \frac{y + 5}{3}. Since x∈Rx \in \mathbb{R} for any y∈Ry \in \mathbb{R}, the function is onto.

    • Example 2: Show g:R→[0,∞)g : \mathbb{R} \rightarrow [0, \infty) such that g(x)=x2g(x) = x^2 is surjective.

      • x2=y  ⟹  x=±yx^2 = y \implies x = \pm\sqrt{y}. Since y≥0y \ge 0, y\sqrt{y} is a real number, so preimages exist for all yy in the codomain.

    • Example 3: Show f:R→Rf : \mathbb{R} \rightarrow \mathbb{R} such that f(x)=x3+2f(x) = x^3 + 2 is onto.

      • x3+2=y  ⟹  x=y−23x^3 + 2 = y \implies x = \sqrt[3]{y - 2}. Since cube roots of all real numbers are real, a preimage always exists.

Bijective Functions and One-to-One Correspondence

  • A function is bijective (or a one-to-one correspondence) if it is both injective and surjective.

  • Example: Show h(x)=2x+3h(x) = 2x + 3 is bijective.

    • Case I (Injective): 2x1+3=2x2+3  ⟹  2x1=2x2  ⟹  x1=x22x_1 + 3 = 2x_2 + 3 \implies 2x_1 = 2x_2 \implies x_1 = x_2.

    • Case II (Onto): Let y∈Ry \in \mathbb{R}, then 2x+3=y  ⟹  x=y−322x + 3 = y \implies x = \frac{y - 3}{2}. Preimage exists for all y∈Ry \in \mathbb{R}.

    • Conclusion: Since both conditions are satisfied, hh is a bijection.

Increasing and Decreasing Functions

  • Let ff be a function with domain and codomain as subsets of the set of real numbers.

  • Increasing: f(x)≤f(y)f(x) \le f(y) whenever x<yx < y.

  • Strictly Increasing: f(x)<f(y)f(x) < f(y) whenever x<yx < y.

  • Decreasing: f(x)≥f(y)f(x) \ge f(y) whenever x<yx < y.

  • Strictly Decreasing: f(x)>f(y)f(x) > f(y) whenever x<yx < y.

  • Derivative Test:

    • If f′(x)>0f'(x) > 0 for all xx in the domain, then ff is an increasing function.

    • If f′(x)<0f'(x) < 0 for all xx in the domain, then ff is a decreasing function.

  • Example: Prove f(x)=2x−1f(x) = 2x - 1 is increasing.

    • Proof by comparison: If x<yx < y, then 2x<2y2x < 2y, and 2x−1<2y−12x - 1 < 2y - 1, so f(x)<f(y)f(x) < f(y).

    • Proof by derivative: f′(x)=2f'(x) = 2. Since 2>02 > 0 for all x∈Rx \in \mathbb{R}, ff is increasing.

Inverse Functions

  • Let f:A→Bf : A \rightarrow B be a bijective function.

  • The inverse function, denoted f−1f^{-1}, is defined from B→AB \rightarrow A such that:

    • f−1(b)=a  ⟺  f(a)=bf^{-1}(b) = a \iff f(a) = b.

  • A function is invertible if it is a one-to-one correspondence.

  • If a function is not bijective (either not one-to-one or not onto), an inverse cannot be defined.

    • If not one-to-one: An element bb in the codomain might mapping back to multiple elements in the domain.

    • If not onto: Some element bb in the codomain might have no corresponding element aa in the domain.

  • Example 1: Let f={(a,2),(b,3),(c,1)}f = \{(a, 2), (b, 3), (c, 1)\}. Since it is a bijection, f−1f^{-1} exists: f−1(1)=cf^{-1}(1) = c, f−1(2)=af^{-1}(2) = a, and f−1(3)=bf^{-1}(3) = b.

  • Example 2: For f(x)=x+1f(x) = x + 1 where f:Z→Zf : \mathbb{Z} \rightarrow \mathbb{Z}, solve y=x+1y = x + 1 for xx, resulting in x=y−1x = y - 1. Swap variables to get f−1(x)=x−1f^{-1}(x) = x - 1.

Composition of Functions

  • Let f:A→Bf : A \rightarrow B and g:B→Cg : B \rightarrow C.

  • The composition of ff and gg, written as g∘fg \circ f, is a function from A→CA \rightarrow C.

  • Calculation rule: (g∘f)(x)=g(f(x))(g \circ f)(x) = g(f(x)).

  • Example: Let f(x)=x2f(x) = x^2 and g(x)=3x+1g(x) = 3x + 1 for R→R\mathbb{R} \rightarrow \mathbb{R}.

    • (g∘f)(x)=g(x2)=3x2+1(g \circ f)(x) = g(x^2) = 3x^2 + 1.

    • (f∘g)(x)=f(3x+1)=(3x+1)2(f \circ g)(x) = f(3x + 1) = (3x + 1)^2.

    • (g∘f)(2)=3(22)+1=13(g \circ f)(2) = 3(2^2) + 1 = 13.

    • (f∘g)(2)=[3(2)+1]2=49(f \circ g)(2) = [3(2) + 1]^2 = 49.

  • Key Note: (g∘f)(x)≠(f∘g)(x)(g \circ f)(x) \neq (f \circ g)(x) in general.

Floor and Ceiling Functions

  • Floor Function (⌊x⌋\lfloor x \rfloor): The greatest integer less than or equal to xx.

    • Examples: ⌊4.8⌋=4\lfloor 4.8 \rfloor = 4, ⌊3⌋=3\lfloor 3 \rfloor = 3, ⌊−2.3⌋=−3\lfloor -2.3 \rfloor = -3.

  • Ceiling Function (⌈x⌉\lceil x \rceil): The smallest integer greater than or equal to xx.

    • Examples: ⌈4.2⌉=5\lceil 4.2 \rceil = 5, ⌈3⌉=3\lceil 3 \rceil = 3, ⌈−2.3⌉=−2\lceil -2.3 \rceil = -2.

  • Solving Equations:

    • ⌊x⌋=3  ⟹  3≤x<4\lfloor x \rfloor = 3 \implies 3 \le x < 4.

    • ⌊2x⌋=5  ⟹  5≤2x<6  ⟹  2.5≤x<3\lfloor 2x \rfloor = 5 \implies 5 \le 2x < 6 \implies 2.5 \le x < 3.

    • ⌈x3⌉=4  ⟹  3<x3≤4  ⟹  9<x≤12\lceil \frac{x}{3} \rceil = 4 \implies 3 < \frac{x}{3} \le 4 \implies 9 < x \le 12.

Questions & Discussion

  • Quiz (Relation on Integers): Define a relation RR on the set of integers Z\mathbb{Z} by R={(a,b)∈Z×Z:a≤b}R = \{(a, b) \in \mathbb{Z} \times \mathbb{Z} : a \le b\}. Determine whether RR is reflexive, symmetric, or transitive.

  • Quiz (One-to-One): Determine whether f:R→Rf : \mathbb{R} \rightarrow \mathbb{R}, f(x)=x2f(x) = x^2 is one-to-one.

  • Quiz (One-to-One): Show that f:R∖{1}→Rf : \mathbb{R} \setminus \{1\} \rightarrow \mathbb{R}, f(x)=x+2x−1f(x) = \frac{x + 2}{x - 1} is injective.

  • Quiz (Onto): Let g:[0,∞)→Rg : [0, \infty) \rightarrow \mathbb{R} such that g(x)=x2g(x) = x^2. Show that g(x)g(x) is onto.

  • Quiz (Onto): Show that f:R∖{2}→R∖{1}f : \mathbb{R} \setminus \{2\} \rightarrow \mathbb{R} \setminus \{1\}, f(x)=x−2x+1f(x) = \frac{x - 2}{x + 1} is onto.

  • Quiz (Arithmetic): Determine the value of ⌊5.7⌋+⌈−3.3⌉\lfloor 5.7 \rfloor + \lceil -3.3 \rceil.

  • Quiz (Ceiling Equation): Find all integers nn such that ⌈n4⌉=3\lceil \frac{n}{4} \rceil = 3.