Domain, Codomain, Range

The Three Parts of a Function

Every function f:ABf: A \to B has three important sets:

  • Domain — the set of inputs
  • Codomain — the set of possible outputs
  • Range — the set of outputs that actually get used

Definitions

f:ABf: A \to B

Domain = AA = all inputs

Everything that goes into the function.

Codomain = BB = all possible outputs

Everything that could come out.

Range = outputs that actually occur

Everything that does come out.


Example

f:{1,2,3}{a,b,c,d}f: \{1, 2, 3\} \to \{a, b, c, d\}

f={(1,a),(2,a),(3,b)}f = \{(1, a), (2, a), (3, b)\}

PartValueWhy?
Domain{1,2,3}\{1, 2, 3\}All the inputs
Codomain{a,b,c,d}\{a, b, c, d\}All possible outputs
Range{a,b}\{a, b\}Only a and b get hit

Notice: cc and dd are in the codomain but nothing maps to them.


Range vs Codomain

The range is always a subset of the codomain:

RangeCodomain\text{Range} \subseteq \text{Codomain}

Sometimes they’re equal — every possible output gets used.

Sometimes the range is smaller — some outputs go unused.


Another Example

f(x)=x2 where f:RRf(x) = x^2 \text{ where } f: \mathbb{R} \to \mathbb{R}

  • Domain = R\mathbb{R} (all real numbers can be squared)
  • Codomain = R\mathbb{R} (we declared outputs are real numbers)
  • Range = R0\mathbb{R} \geq 0 (only non-negative numbers come out)

Why? Squaring never gives a negative result. So 5-5 is in the codomain, but no input maps to it.