Mathwords logoMathwords

Codomain — Definition & Example

The codomain of a function is the set of values its outputs are allowed to come from. It is declared ahead of time, so some of its members might never actually be produced as outputs.

For a function written f:A→Bf: A \to B, the set BB is the codomain. Every input a∈Aa \in A must have f(a)∈Bf(a) \in B. The range (image) is f(A)={f(a):a∈A}f(A) = \{f(a) : a \in A\}, which always satisfies f(A)⊆Bf(A) \subseteq B. The codomain is part of the function's definition. Two functions with the same rule and domain but different codomains are, strictly speaking, different functions.

Worked Example

Problem: Let f:{1,2,3}→{1,2,3,4,5,6}f: \{1, 2, 3\} \to \{1, 2, 3, 4, 5, 6\} be defined by f(x)=2xf(x) = 2x. Identify the codomain, find the range, and compare the two sets.
Step 1: Read the codomain from the notation. It is the set written after the arrow.
Codomain={1,2,3,4,5,6}\text{Codomain} = \{1, 2, 3, 4, 5, 6\}
Step 2: Apply the rule to every input in the domain {1,2,3}\{1, 2, 3\} to find the actual outputs.
f(1)=2,f(2)=4,f(3)=6f(1) = 2, \quad f(2) = 4, \quad f(3) = 6
Step 3: Collect the outputs into the range. Then check which members of the codomain are never reached.
Range={2,4,6}⊆{1,2,3,4,5,6}\text{Range} = \{2, 4, 6\} \subseteq \{1, 2, 3, 4, 5, 6\}
Answer: The codomain is {1,2,3,4,5,6}\{1, 2, 3, 4, 5, 6\} and the range is {2,4,6}\{2, 4, 6\}. The values 1, 3, and 5 are in the codomain, but no input produces them.

Why It Matters

In precalculus and later in discrete math, you call a function onto (surjective) exactly when its range equals its codomain. That condition helps decide whether a function has an inverse. Programmers use the same idea when they declare a function's return type, such as integer, before knowing which specific values it will return.

Common Mistakes

Mistake: Treating the codomain and the range as the same set. For example, saying the codomain of f(x)=x2f(x) = x^2 is [0,∞)[0, \infty) when the function was given as f:R→Rf: \mathbb{R} \to \mathbb{R}.
Correction: The codomain is whatever set the definition declares, which is R\mathbb{R} here. The range is the set of outputs actually produced, [0,∞)[0, \infty). The range is always a subset of the codomain, but it can be smaller.

Related Terms