Course contentsShow
← Computer Science
Lesson 81 of 2,8722. Discrete Mathematics for CSFree lesson

Inverse Functions

Defining inverse functions and determining when a function has an inverse (bijection requirement).

Inverse Functions

What you'll learn: How to "undo" a function and determine when that's possible.

The Core Idea

An inverse function reverses what the original function does. If function f takes input x and produces output y, then the inverse function f⁻¹ takes y and gives you back x.

Think of it like encoding and decoding: if encode("hello") produces "jgnnq", then decode("jgnnq") should return "hello". The decode function is the inverse of encode.

The Bijection Requirement

Not every function has an inverse. For f⁻¹ to exist as a proper function, f must be bijective (both injective and surjective):

  • Injective (one-to-one): Every output comes from exactly one input. If f(3) = 9 and f(-3) = 9, which value should f⁻¹(9) return? This ambiguity breaks the inverse.

  • Surjective (onto): Every possible output value is actually produced by some input. Otherwise, f⁻¹ would have "gaps" where it's undefined.

Example

Consider f: {1,2,3} → {a,b,c} where f(1)=a, f(2)=b, f(3)=c. This is bijective, so the inverse exists:

  • f⁻¹(a) = 1
  • f⁻¹(b) = 2
  • f⁻¹(c) = 3

But if g(1)=a and g(2)=a, then g⁻¹(a) is undefined as a function—should it be 1 or 2?

Verification

To verify an inverse: f(f⁻¹(y)) = y and f⁻¹(f(x)) = x for all valid inputs.

Key Takeaway: An inverse function exists if and only if the original function is bijective—ensuring every output has exactly one corresponding input.