BCA151 Discrete Structure

Discrete StructureUnit 118 min read

Functions, Composition & Inverses: Types, Properties & Applications

Unit 11 of Discrete Structure explores injective/surjective/bijective functions, function composition, inverse functions, and their real-world applications in algorithms, databases, and cryptography—with visual proofs, step-by-step examples, and exam-focused problem-solving techniques.

TAKEAWAYS:

  • Injective vs. Surjective vs. Bijective: Master the definitions and visual tests (horizontal/vertical line tests) to classify functions.
  • Composition ≠ Multiplication: Understand (f∘g)(x) means "apply g first, then f"—trace with tables to avoid mistakes.
  • Inverses Exist Only for Bijective Functions: Learn how to algebraically derive f⁻¹(x) and verify it using f(f⁻¹(x)) = x.
  • Real-World Mappings: Functions model database joins (SQL), encryption (Khalti), and pathfinding (Pathao routes)—connect theory to apps.
  • Proof Techniques: Use contradiction and direct substitution to prove injectivity/surjectivity.
  • Exam Pitfalls: Avoid assuming (f∘g)⁻¹ = g⁻¹∘f⁻¹ without proof; always verify domains/codomains.

1. Types of Functions: Injective, Surjective, Bijective

Definitions with Visual Tests

A function f: A → B can be classified by how it maps elements of A to B:

Type Definition Visual Test Example
Injective Distinct inputs map to distinct outputs (f(a) = f(b) ⇒ a = b). Horizontal line test: No two points share the same y-value. f(x) = 2x + 1 (one-to-one).
Surjective Every element in B is mapped by some a ∈ A (onto). Covered codomain: The graph "hits" every y-value in B. f: ℝ → ℝ, f(x) = x³ (onto).
Bijective Both injective and surjective (one-to-one and onto). Perfect pairing: Every x has a unique y, and every y is covered. f: ℝ → ℝ, f(x) = eˣ (bijective).

Worked Example: Classify and Prove

Problem: Show f: ℝ → ℝ, f(x) = 5x − 7 is bijective. Find f⁻¹(x).

Solution:

  1. Injective Proof (Contradiction): Assume f(a) = f(b). Then: Thus, injective.

  2. Surjective Proof (Existence): For any y ∈ ℝ, solve y = 5x − 7: Thus, surjective.

  3. Inverse Function: Swap x and y in y = 5x − 7: So, f⁻¹(x) = (x + 7)/5.

Verification:

-5-4-3-2-112345-30-20-101020xyf⁻¹(x) = (x + 7)/5f(x) = 5x - 7f⁻¹(-2) = 0f⁻¹(0) = 1.4f(1.4) = 0
Graphical verification of f⁻¹(f(x)) = x and f(f⁻¹(x)) = x

Key Insight: Inverses undo the original function.


2. Function Composition: (f∘g)(x)

How It Works

Composition f∘g means "apply g first, then f":

Caution: Order matters! (f∘g) ≠ (g∘f) unless f and g commute.

Worked Example: Real-World Scenario

Problem: Pathao’s ride-hailing system uses two functions:

  • g(x): Estimates fare based on distance x (km): g(x) = 10x + 50.
  • f(y): Adds a 10% surge fee: f(y) = 1.1y. Find (f∘g)(x) and interpret it.

Solution:

  1. Compute (f∘g)(x):
  2. Interpretation:
    • g(x): Base fare (e.g., 5 km → ₹100).
    • f(g(x)): Total fare with surge (₹110).

Visual Trace:

flowchart TD
    A["Distance (x km)"] -->|"g(x)"| B["Base Fare (₹10x+50)"]
    B -->|"f(y)"| C["Total Fare (₹1.1y)"]
    C --> D["(f∘g)(x) = 11x + 55"]

3. Inverse Functions and Their Properties

When Does an Inverse Exist?

Only bijective functions have inverses. For non-bijective functions:

  • Injective but not surjective: Restrict codomain to make it bijective (e.g., f(x) = x² on [0, ∞)).
  • Surjective but not injective: No inverse unless you allow relations (multivalued functions).

Worked Example: Bank Loan Interest

Problem: A bank offers a loan with interest calculated by f(P) = P(1 + 0.05t), where P is principal, t is time (years). Find f⁻¹ to determine principal from total repayment.

123456789101000110012001300140015001600yLoan Balance (₹1000, 5% interest)₹1000₹1050₹1102.5
Exponential growth of loan interest over time

Solution:

  1. Rewrite y = P(1 + 0.05t) as P = y / (1 + 0.05t). But to find f⁻¹, treat t as fixed:
  2. Verification:

Real-World Tie:

  • Khalti’s Transaction ID: Acts like an injective function mapping user actions to unique IDs.
  • NEPSE Stock Codes: Bijective mapping between company names and ticker symbols (e.g., NICASIA → NICASIA).

4. Composition of Inverses

Key Theorem

If f and g are bijective:

Proof:

graph LR
    A["(f∘g)⁻¹"] -->|"Definition"| B["x such that (f∘g)(x) = y"]
    B --> C["g(x) = f⁻¹(y)"]
    C --> D["x = g⁻¹(f⁻¹(y))"]
    D --> E["Thus, (f∘g)⁻¹(y) = g⁻¹(f⁻¹(y))"]

Worked Example: Encryption (Khalti-Style)

Problem: Let f(x) = 3x + 2 (encrypt) and g(x) = x/2 (decrypt). Show (f∘g)⁻¹ = g⁻¹∘f⁻¹.

PlaintextEncryptedDecrypted
Encryption/decryption as function composition

Solution:

  1. Compute f⁻¹ and g⁻¹:
    • f⁻¹(x) = (x − 2)/3.
    • g⁻¹(x) = 2x.
  2. Compute (f∘g)⁻¹ directly: Inverse: x = (3y/2) + 2 ⇒ y = (2x − 4)/3.
  3. Compute g⁻¹∘f⁻¹: Matches!

5. Common Mistakes and Pitfalls

  1. Assuming (f∘g)⁻¹ = f⁻¹∘g⁻¹:
    • Wrong: Order matters! Correct: (f∘g)⁻¹ = g⁻¹∘f⁻¹.
  2. Ignoring Domains/Codomains:
    • Example: f: [0,∞) → ℝ, f(x) = x² is bijective only if codomain is restricted to [0,∞).
  3. Composition vs. Multiplication:
    • (f∘g)(x) ≠ f(x) * g(x). Always evaluate step-by-step.

In the Real World

  1. Pathao’s Ride Matching:

    • Function: f(user_id) → driver_id (injective, since one user gets one driver).
    • Composition: g(driver_id) → location ∘ f(user_id) maps a user to their driver’s location.
    • Inverse: f⁻¹(driver_id) → user_id (used for dispute resolution).
  2. Khalti’s Transaction IDs:

    • Bijective Function: f(user_action) → unique_transaction_ID.
    • Why Bijective? Ensures no two actions share an ID (injective) and every action gets an ID (surjective).
    • Inverse: f⁻¹(ID) → user_action (used for refunds).
  3. Daraz’s Order Queue:

    • Partial Order: Orders are processed based on time + priority (not a total order).
    • Function Composition: g(order) → delivery_status ∘ f(order) → warehouse_assignment tracks order flow.

Exam Tip

  1. For Proofs:

    • Injective: Use contradiction (f(a) = f(b) ⇒ a = b).
    • Surjective: Show for any y ∈ B, there exists x ∈ A such that f(x) = y.
    • Bijective: Combine both proofs or use the inverse.
  2. For Composition:

    • Always substitute step-by-step. Example: Given f(x) = x² + 1, g(x) = 2x:
    • Never write (f∘g)(x) = f(x) * g(x).
  3. Inverse Functions:

    • To find f⁻¹(x), solve y = f(x) for x in terms of y.
    • Verify: Check f(f⁻¹(x)) = x and f⁻¹(f(x)) = x.
  4. Diagrams Save Marks:

    • Draw mapping diagrams for injective/surjective functions.
    • Use flowcharts for composition (e.g., Pathao’s fare calculation).
  5. Real-World Questions:

    • Expect problems like:
      • "A bank charges interest as f(P) = P(1 + r)². If r = 0.05, find the inverse to calculate principal from maturity amount."
      • "Pathao’s surge pricing is f(x) = 1.2x. If base fare is g(d) = 10d + 50, express total fare as a composition."

Final Reminder:

"A function is like a vending machine: injective means no two inputs give the same output; surjective means every snack is available; bijective means every input gives a unique snack, and you can reverse the process." — Discrete Math Proverb

Based on the TU BCA syllabus for Discrete Structure (BCA151), unit 11.

Discussion

Loading…