Sets, Relations and Functions: Venn Diagrams, Domain and Range

Sets are the language in which relations and functions are defined, and functions are the objects that calculus studies. Entry tests ask you to combine sets, count with Venn diagrams, test whether a relation is reflexive, symmetric or transitive, find the domain and range of a function, decide whether it is one-one or onto, and work with composite and inverse functions. Most questions need careful definitions rather than long working.

Asked in: ECAT, NUST NET, JEE Main, FSc and Class 11-12 boards

Sets and set operations

A set is a well-defined collection of objects called elements. The union A ∪ B contains every element in A or B or both, the intersection A ∩ B contains the elements common to both, and the difference A − B contains the elements of A that are not in B.

With a universal set U, the complement A′ = U − A. A set with n elements has 2ⁿ subsets, including the empty set ∅ and the set itself; the set of all these subsets is the power set P(A).

Laws of sets and De Morgan's laws

Union and intersection are commutative and associative, and each distributes over the other. These laws work like the rules of ordinary algebra and are easy to confirm with a Venn diagram.

De Morgan's laws describe the complement of a union or an intersection: the complement swaps ∪ and ∩ and complements each set.

Counting with Venn diagrams

When two sets overlap, adding n(A) and n(B) counts the common part twice, so subtract it once. For three sets the pairwise overlaps are subtracted, but then the centre has been removed too often, so it is added back.

In survey questions, the number belonging to none of the sets is the total minus n(A ∪ B) or n(A ∪ B ∪ C). Filling the Venn diagram from the centre outwards avoids double counting.

Cartesian product and relations

A × B is the set of all ordered pairs (a, b) with a ∈ A and b ∈ B, so n(A × B) = n(A) × n(B). A relation from A to B is any subset of A × B, which is why there are 2 raised to the power mn relations when n(A) = m and n(B) = n.

A relation R on a set A is reflexive if (a, a) ∈ R for every a in A, symmetric if (a, b) ∈ R always forces (b, a) ∈ R, and transitive if (a, b) and (b, c) in R always force (a, c) ∈ R. A relation with all three properties is an equivalence relation.

Functions, domain and range

A function f from A to B assigns to every element of A exactly one element of B. A is the domain, B is the codomain, and the set of values actually taken is the range, which is a subset of the codomain.

For a real formula, the natural domain excludes values that make a denominator zero, put a negative number under an even root, or make a logarithm's argument zero or negative. Find the range by solving y = f(x) for x, or by completing the square.

One-one, onto and bijective functions

f is one-one (injective) if different inputs always give different outputs: f(a) = f(b) forces a = b. A strictly increasing or strictly decreasing function is one-one; a function such as x² that gives the same value at 2 and −2 is not.

f is onto (surjective) if its range equals its codomain. A function that is both one-one and onto is a bijection. From a set of m elements to a set of n elements, there are n(n − 1)(n − 2)… (m factors) one-one functions when m ≤ n.

Composite and inverse functions

The composite (f∘g)(x) = f(g(x)) applies g first and then f. In general f∘g and g∘f are different, so the order matters.

A function has an inverse exactly when it is a bijection. To find f⁻¹, write y = f(x), solve for x in terms of y, then swap the letters. The graphs of f and f⁻¹ are mirror images in the line y = x, and f(f⁻¹(x)) = x.

Solved examples

  1. If A = {1, 2, 3, 4, 5} and B = {4, 5, 6, 7}, find A ∪ B, A ∩ B, A − B and B − A.
    1. A ∪ B lists every element once: {1, 2, 3, 4, 5, 6, 7}.
    2. A ∩ B keeps the common elements: {4, 5}.
    3. A − B removes 4 and 5 from A: {1, 2, 3}. B − A removes 4 and 5 from B: {6, 7}.
    Answer: {1, 2, 3, 4, 5, 6, 7}, {4, 5}, {1, 2, 3} and {6, 7}
  2. Let U = {1, 2, 3, 4, 5, 6, 7, 8}, A = {1, 2, 3, 4} and B = {3, 4, 5, 6}. Verify that (A ∪ B)′ = A′ ∩ B′.
    1. A ∪ B = {1, 2, 3, 4, 5, 6}, so (A ∪ B)′ = {7, 8}.
    2. A′ = {5, 6, 7, 8} and B′ = {1, 2, 7, 8}.
    3. A′ ∩ B′ = {7, 8}, which matches, as De Morgan's law says.
    Answer: Both sides equal {7, 8}
  3. In a class of 60 students, 35 study Physics, 30 study Mathematics and 12 study both. How many study neither subject, and how many study only Physics?
    1. n(P ∪ M) = n(P) + n(M) − n(P ∩ M) = 35 + 30 − 12 = 53.
    2. Neither = 60 − 53 = 7.
    3. Only Physics = n(P) − n(P ∩ M) = 35 − 12 = 23.
    Answer: 7 study neither; 23 study only Physics
  4. On A = {1, 2, 3}, let R = {(1, 1), (2, 2), (3, 3), (1, 2), (2, 1)}. Is R an equivalence relation?
    1. Reflexive: (1, 1), (2, 2) and (3, 3) are all in R. Yes.
    2. Symmetric: the only non-diagonal pairs are (1, 2) and (2, 1), and each has its reverse. Yes.
    3. Transitive: (1, 2) and (2, 1) need (1, 1), which is present; (2, 1) and (1, 2) need (2, 2), also present. No pair fails. Yes.
    4. All three hold, so R is an equivalence relation. Its classes are {1, 2} and {3}.
    Answer: Yes, R is an equivalence relation
  5. Find the domain and range of f(x) = √(9 − x²).
    1. The square root needs 9 − x² ≥ 0, so x² ≤ 9, giving −3 ≤ x ≤ 3. Domain: [−3, 3].
    2. Inside the root, 9 − x² is largest (9) at x = 0 and smallest (0) at x = ±3.
    3. So f(x) runs from √0 = 0 to √9 = 3. Range: [0, 3].
    Answer: Domain [−3, 3], range [0, 3]
  6. If f(x) = 2x + 3 and g(x) = x², find (f∘g)(x), (g∘f)(x) and f⁻¹(x).
    1. (f∘g)(x) = f(x²) = 2x² + 3.
    2. (g∘f)(x) = g(2x + 3) = (2x + 3)² = 4x² + 12x + 9, which is different, so order matters.
    3. For the inverse, y = 2x + 3 gives x = (y − 3)/2. Swapping letters, f⁻¹(x) = (x − 3)/2.
    4. Check: f(f⁻¹(x)) = 2 × (x − 3)/2 + 3 = x.
    Answer: 2x² + 3, (2x + 3)² and (x − 3)/2

Exam shortcuts

Common mistakes

Practice MCQs

  1. How many subsets does the set {1, 2, 3} have?
    A) 6
    B) 9
    C) 8
    D) 3
    Answer: C) 8 — A set with 3 elements has 2³ = 8 subsets: ∅, three singletons, three pairs and the whole set. 6 leaves out ∅ and the set itself, and 9 is 3².
  2. If n(A) = 20, n(B) = 15 and n(A ∩ B) = 6, then n(A ∪ B) is:
    A) 29
    B) 35
    C) 23
    D) 41
    Answer: A) 29 — n(A ∪ B) = 20 + 15 − 6 = 29. Simply adding gives 35, which counts the 6 common elements twice; adding 6 instead of subtracting gives 41.
  3. By De Morgan's law, (A ∩ B)′ equals:
    A) (A ∪ B)′
    B) A ∪ B′
    C) A′ ∪ B′
    D) A′ ∩ B′
    Answer: C) A′ ∪ B′ — Complementing an intersection gives the union of the complements: (A ∩ B)′ = A′ ∪ B′. A′ ∩ B′ is the complement of A ∪ B, which is the other De Morgan law.
  4. In a group of 100 people, 60 drink tea, 50 drink coffee and 20 drink both. How many drink neither?
    A) 10
    B) 30
    C) 0
    D) 20
    Answer: A) 10 — n(T ∪ C) = 60 + 50 − 20 = 90, so 100 − 90 = 10 drink neither. Forgetting to subtract the overlap gives 110, which would suggest 0, and 30 is the number who drink only coffee.
  5. Of 100 students, 50 play cricket, 40 football and 30 hockey; 15 play cricket and football, 10 football and hockey, 12 cricket and hockey, and 5 play all three. How many play none of the three?
    A) 12
    B) 22
    C) 17
    D) 7
    Answer: A) 12 — n(C ∪ F ∪ H) = 120 − 37 + 5 = 88, so 100 − 88 = 12 play none. Leaving out the +5 for the centre gives 83 and 17; subtracting it gives 78 and 22.
  6. If n(A) = 3 and n(B) = 2, the number of relations from A to B is:
    A) 9
    B) 64
    C) 32
    D) 6
    Answer: B) 64 — A × B has 3 × 2 = 6 ordered pairs, and every subset of A × B is a relation, so there are 2⁶ = 64. 6 counts the pairs, not the relations.
  7. On A = {1, 2, 3}, the relation R = {(1, 1), (2, 2), (3, 3), (1, 2)} is:
    A) Reflexive and symmetric, but not transitive
    B) Symmetric and transitive, but not reflexive
    C) An equivalence relation
    D) Reflexive and transitive, but not symmetric
    Answer: D) Reflexive and transitive, but not symmetric — All three diagonal pairs are present, so R is reflexive. (1, 2) is in R but (2, 1) is not, so it is not symmetric and hence not an equivalence relation. Every chain such as (1, 1), (1, 2) leads to a pair already in R, so it is transitive.
  8. The domain of f(x) = √(x² − 9) is:
    A) All real x except ±3
    B) x ≤ −3 or x ≥ 3
    C) x ≥ 3 only
    D) −3 ≤ x ≤ 3
    Answer: B) x ≤ −3 or x ≥ 3 — We need x² − 9 ≥ 0, that is x² ≥ 9, which holds for x ≤ −3 or x ≥ 3. The interval −3 ≤ x ≤ 3 is where x² ≤ 9, the domain of √(9 − x²), and x ≥ 3 alone forgets the negative values such as x = −5.
  9. The range of f(x) = x² + 4x + 7, for real x, is:
    A) [7, ∞)
    B) [−2, ∞)
    C) [3, ∞)
    D) (3, ∞)
    Answer: C) [3, ∞) — Complete the square: x² + 4x + 7 = (x + 2)² + 3, which is smallest, 3, at x = −2. So the range is [3, ∞), with 3 included because it is attained. 7 is f(0), and −2 is where the minimum occurs, not its value.
  10. Which of these functions from R to R is one-one?
    A) f(x) = x² + 2
    B) f(x) = x³ + 2
    C) f(x) = cos x
    D) f(x) = |x| + 2
    Answer: B) f(x) = x³ + 2 — x³ + 2 is strictly increasing, so different inputs give different outputs. x² + 2 and |x| + 2 take the same value at 1 and −1, and cos x repeats every 2π, so none of those is one-one.
  11. The function f: R → R defined by f(x) = x² is:
    A) Onto but not one-one
    B) Both one-one and onto
    C) Neither one-one nor onto
    D) One-one but not onto
    Answer: C) Neither one-one nor onto — f(2) = f(−2) = 4, so f is not one-one. Its range is [0, ∞), which is smaller than the codomain R (no x gives −1), so it is not onto either.
  12. If f(x) = 3x − 1 and g(x) = x² + 1, then (f∘g)(2) equals:
    A) 15
    B) 26
    C) 50
    D) 14
    Answer: D) 14 — Inside first: g(2) = 4 + 1 = 5, then f(5) = 15 − 1 = 14. Applying f first gives g(f(2)) = g(5) = 26, which is (g∘f)(2).
  13. The inverse of f(x) = (2x + 1)/(x − 3), x ≠ 3, is:
    A) (x − 3)/(2x + 1)
    B) (3x + 1)/(x − 2)
    C) (3x − 1)/(x − 2)
    D) (2x + 1)/(x + 3)
    Answer: B) (3x + 1)/(x − 2) — From y = (2x + 1)/(x − 3): xy − 3y = 2x + 1, so x(y − 2) = 3y + 1 and x = (3y + 1)/(y − 2). Swapping letters gives (3x + 1)/(x − 2). The reciprocal (x − 3)/(2x + 1) is 1/f(x), not f⁻¹(x).
  14. How many one-one functions are there from a set of 3 elements to a set of 5 elements?
    A) 60
    B) 10
    C) 125
    D) 243
    Answer: A) 60 — The first element has 5 possible images, the second 4 (it must differ) and the third 3: 5 × 4 × 3 = 60. 125 = 5³ counts all functions, 243 = 3⁵ reverses the roles, and 10 = 5C3 ignores the order of the images.
  15. The number of onto functions from {1, 2, 3} to {a, b} is:
    A) 3
    B) 9
    C) 8
    D) 6
    Answer: D) 6 — There are 2³ = 8 functions in all. Only two of them miss an element of the codomain: the one sending everything to a and the one sending everything to b. So 8 − 2 = 6 are onto. 9 = 3² swaps the base and the power.

Questions

What is the difference between a relation and a function?

A relation from A to B is any set of ordered pairs (a, b). A function is a special relation in which every element of A appears as a first entry exactly once, so each input has one and only one output.

How do I check whether a relation is transitive?

Look at every pair of pairs where the second entry of one equals the first entry of the other, such as (a, b) and (b, c). For each such chain the pair (a, c) must be in the relation. If even one is missing, the relation is not transitive.

Why does a function need to be one-one and onto to have an inverse?

The inverse must send each output back to exactly one input. If f is not one-one, some output came from two inputs, so the inverse would not be single-valued. If f is not onto, some codomain elements have no input to return to.

Is f∘g ever equal to g∘f?

Sometimes, for example when g is the inverse of f, or for f(x) = 2x and g(x) = 3x. But in general they are different, so always compute the inner function first.