How Does a Function Use Its Codomain?

Suppose

\[ f:A\to B. \]

We already know what makes \(f\) a function: every input in \(A\) receives exactly one output in \(B\).

Now we can ask more detailed questions.

Those questions lead to three important classifications:

\[ \boxed{ \text{injective}, \qquad \text{surjective}, \qquad \text{bijective} } \]

These are not three different kinds of formulas. They describe how a function connects two sets.

Injective Functions

A function is injective, or one-to-one, when different inputs always produce different outputs.

One standard definition is:

\[ \boxed{ f(a)=f(b)\implies a=b } \]

An equivalent form is:

\[ a\neq b \implies f(a)\neq f(b). \]

So an injective function has no output collisions.

Example

Let

\[ f:\mathbb{R}\to\mathbb{R} \]

be defined by

\[ f(x)=2x+3. \]

If

\[ f(a)=f(b), \]

then

\[ 2a+3=2b+3. \]

Subtract \(3\):

\[ 2a=2b. \]

Divide by \(2\):

\[ a=b. \]

Therefore \(f\) is injective.

A Nonexample

Consider

\[ g(x)=x^2 \]

on the real numbers.

We have

\[ g(3)=9 \]

and

\[ g(-3)=9. \]

Two different inputs produce the same output, so

\[ g:\mathbb{R}\to\mathbb{R} \]

is not injective.

Surjective Functions

A function is surjective, or onto, when every element of the codomain is reached by at least one input.

If

\[ f:A\to B, \]

then \(f\) is surjective when

\[ \boxed{ \forall b\in B,\ \exists a\in A \text{ such that } f(a)=b } \]

Equivalently, the range equals the codomain:

\[ \boxed{ \operatorname{Ran}(f)=B } \]

Example

Consider

\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=2x+3. \]

Take any target value

\[ y\in\mathbb{R}. \]

To reach that output, solve

\[ 2x+3=y. \]

This gives

\[ x=\frac{y-3}{2}. \]

That input is real for every real \(y\), so every element of the codomain is reached.

Therefore \(f\) is surjective.

A Nonexample

Consider

\[ g:\mathbb{R}\to\mathbb{R}, \qquad g(x)=x^2. \]

Negative real numbers are in the codomain but never occur as outputs.

Thus

\[ \operatorname{Ran}(g)=[0,\infty) \]

and

\[ \operatorname{Ran}(g)\neq\mathbb{R}. \]

So \(g\) is not surjective onto \(\mathbb{R}\).

Bijective Functions

A function is bijective when it is both injective and surjective.

\[ \boxed{ \text{bijective} = \text{injective} + \text{surjective} } \]

A bijection pairs every domain element with exactly one codomain element and uses every codomain element exactly once.

That creates a one-to-one correspondence between the two sets.

Example

The function

\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=2x+3 \]

is injective and surjective, so it is bijective.

This means the real numbers in the domain and codomain are paired one-to-one through the rule \(2x+3\).

Why Bijections Matter

A bijection is the precise mathematical structure behind the phrase same cardinality.

If there is a bijection

\[ f:A\to B, \]

then

\[ |A|=|B|. \]

This connection works for finite sets and extends to infinite sets as well.

Reading Mapping Diagrams

Mapping diagrams make these three properties visually clear.

Injective but Not Surjective

Injective but not surjective mapping Three domain elements map to three different codomain elements, while one codomain element is unused. A B 1 2 3 a b c d
No two inputs share an output, so the function is injective. But \(d\) is unused, so the function is not surjective.

Surjective but Not Injective

Surjective but not injective mapping Four domain elements map onto three codomain elements, with two inputs sharing one output. A B 1 2 3 4 a b c
Every codomain element is used, so the function is surjective. Inputs \(2\) and \(3\) share \(b\), so it is not injective.

Bijective

Bijective mapping Three domain elements map one-to-one onto three codomain elements. A B 1 2 3 a b c
Every output is used exactly once. The function is both injective and surjective, so it is bijective.

Why the Codomain Matters

Surjectivity cannot be decided from a formula alone.

The codomain matters.

Consider the same rule

\[ f(x)=x^2. \]

If we define

\[ f:\mathbb{R}\to\mathbb{R}, \]

then \(f\) is not surjective because negative real numbers are never reached.

But if we define

\[ g:\mathbb{R}\to[0,\infty), \qquad g(x)=x^2, \]

then \(g\) is surjective because every nonnegative real number has at least one real square root.

The formula is the same, but the mapping is different because the codomain is different.

Injectivity Can Depend on the Domain

The rule

\[ x^2 \]

is not injective on

\[ \mathbb{R} \]

because \(x\) and \(-x\) have the same square.

But the restricted function

\[ h:[0,\infty)\to[0,\infty), \qquad h(x)=x^2 \]

is injective.

Thus both the domain and codomain are part of the function's structure.

Testing Injectivity Algebraically

A standard algebraic strategy is to assume two outputs are equal and ask whether that forces the inputs to be equal.

Start with

\[ f(a)=f(b). \]

Then manipulate the equation.

If the only possible conclusion is

\[ a=b, \]

the function is injective.

Example

Let

\[ f(x)=5x-7. \]

Assume

\[ f(a)=f(b). \]

Then

\[ 5a-7=5b-7. \]

So

\[ 5a=5b \]

and therefore

\[ a=b. \]

Thus \(f\) is injective on \(\mathbb{R}\).

Finding a Counterexample

To show that a function is not injective, it is enough to find distinct inputs \(a\neq b\) satisfying

\[ f(a)=f(b). \]

For \(f(x)=x^2\), the pair \(a=2\), \(b=-2\) is enough:

\[ f(2)=f(-2)=4. \]

Testing Surjectivity Algebraically

To test surjectivity, begin with an arbitrary target value in the codomain.

Suppose

\[ f:A\to B. \]

Choose

\[ y\in B \]

and ask whether the equation

\[ f(x)=y \]

has at least one solution

\[ x\in A. \]

If every \(y\in B\) can be reached, the function is surjective.

Example

Let

\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=3x-4. \]

Given any

\[ y\in\mathbb{R}, \]

solve

\[ 3x-4=y. \]

Then

\[ x=\frac{y+4}{3}. \]

This is real for every real \(y\), so every codomain value has a preimage.

Therefore \(f\) is surjective.

Graphical Tests

Graphs can help us recognize injective and surjective behavior when the domain and codomain are understood.

Horizontal-Line Test for Injectivity

A function is injective if every horizontal line intersects its graph at most once.

Why?

A horizontal line fixes one output value \(y\). If it intersects the graph twice, then two different inputs produce the same output.

That violates injectivity.

Surjectivity from a Graph

To decide whether a graph is surjective, compare the graph's range with the declared codomain.

If the codomain is \(\mathbb{R}\), then a surjective graph must reach every real \(y\)-value.

A graph alone cannot settle surjectivity unless the codomain is known.

Example

The graph of

\[ f(x)=x^3 \]

passes the horizontal-line test and reaches every real \(y\)-value.

Thus

\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=x^3 \]

is bijective.

Finite Sets and Cardinality

When the domain and codomain are finite, cardinality gives us useful constraints.

Suppose

\[ f:A\to B. \]

Injective Functions Need Enough Targets

If \(f\) is injective, then distinct inputs require distinct outputs. Therefore,

\[ \boxed{|A|\leq|B|}. \]

If

\[ |A|>|B|, \]

an injective function from \(A\) to \(B\) is impossible.

This is a direct form of the pigeonhole principle.

Surjective Functions Need Enough Inputs

If \(f\) is surjective, every codomain element must be reached. Therefore,

\[ \boxed{|A|\geq|B|}. \]

Bijections Require Equal Cardinality

If \(f\) is bijective, then

\[ \boxed{|A|=|B|}. \]

Equal Finite Sizes Simplify the Test

If \(A\) and \(B\) are finite and

\[ |A|=|B|, \]

then an injective function \(f:A\to B\) is automatically surjective, and a surjective function is automatically injective.

For finite sets of equal size, either property is enough to establish a bijection.

Bijections and Inverse Functions

A bijection can be reversed without ambiguity.

If

\[ f:A\to B \]

is bijective, then every \(b\in B\) comes from exactly one \(a\in A\).

That allows us to define a genuine inverse function

\[ f^{-1}:B\to A. \]

The inverse reverses the mapping:

\[ f(a)=b \iff f^{-1}(b)=a. \]

Why Injectivity Is Needed

If two different inputs shared one output, reversing the mapping would give one input to the inverse with two possible outputs.

That would fail the function rule.

Why Surjectivity Is Needed

If some codomain element were unused, the inverse would have a domain element with no output.

So a function has an inverse function from its entire codomain back to its entire domain exactly when it is bijective.

Practical Applications

Unique Identifiers

Suppose employees are assigned badge numbers.

If no two employees may share a badge number, the assignment must be injective.

If every available badge number must also be assigned, the mapping is surjective.

If both conditions hold, the assignment is bijective.

Database Keys

A primary key should identify at most one record.

That is an injective relationship from records to key values.

If the permitted key space contains many unused values, the mapping need not be surjective.

Seat Assignments

Suppose each ticket holder receives one seat.

An injective assignment prevents two people from receiving the same seat.

A surjective assignment uses every seat.

A bijective assignment means every person has a unique seat and every seat is occupied.

Data Encoding

A lossless encoding must preserve enough information to recover the original input uniquely.

Injectivity is therefore essential: distinct inputs cannot collapse to the same encoded value if perfect recovery is required.

Unit Conversion

The Celsius-to-Fahrenheit function

\[ F(C)=\frac95C+32 \]

maps \(\mathbb{R}\) bijectively onto \(\mathbb{R}\).

Every Celsius temperature corresponds to exactly one Fahrenheit temperature, and every Fahrenheit temperature corresponds back to exactly one Celsius temperature.

Worked Examples

Example 1: Classifying a Linear Function

Let

\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=4x+1. \]

A nonzero-slope linear function is injective because equal outputs force equal inputs.

It is surjective because for any real \(y\),

\[ 4x+1=y \]

has the real solution

\[ x=\frac{y-1}{4}. \]

Therefore \(f\) is bijective.

Example 2: Squaring on the Reals

Let

\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=x^2. \]

It is not injective because

\[ f(2)=f(-2)=4. \]

It is not surjective because no negative real number is reached.

Therefore it is neither injective nor surjective.

Example 3: Restricting the Squaring Function

Now define

\[ g:[0,\infty)\to[0,\infty), \qquad g(x)=x^2. \]

On this restricted domain, different inputs have different squares, so \(g\) is injective.

Every nonnegative target \(y\) is reached by

\[ x=\sqrt{y}. \]

So \(g\) is surjective.

Therefore \(g\) is bijective.

Example 4: Finite Mapping

Let

\[ A=\{1,2,3\}, \qquad B=\{a,b,c,d\}, \]

and

\[ f=\{(1,a),(2,b),(3,c)\}. \]

No outputs repeat, so \(f\) is injective.

But \(d\) is not reached, so \(f\) is not surjective.

Example 5: Surjective but Not Injective

Let

\[ A=\{1,2,3,4\}, \qquad B=\{a,b,c\}, \]

and

\[ f=\{(1,a),(2,b),(3,b),(4,c)\}. \]

Every element of \(B\) is reached, so \(f\) is surjective.

But \(2\) and \(3\) both map to \(b\), so \(f\) is not injective.

Example 6: Impossible Injection

Can there be an injective function

\[ f:A\to B \]

if

\[ |A|=8 \]

and

\[ |B|=5? \]

No.

Eight distinct inputs would require eight distinct outputs, but only five codomain elements are available.

Thus an injective mapping is impossible.

Common Errors

1. Confusing Injective with “Is a Function”

A function may send several inputs to the same output.

Injectivity is an additional property, not part of the basic function definition.

2. Forgetting the Codomain When Testing Surjectivity

Surjective means the range equals the declared codomain.

The same formula can be surjective for one codomain and not for another.

3. Thinking Injective Means Every Codomain Element Is Used

That is surjectivity.

Injectivity only says that different inputs do not collide at the same output.

4. Thinking Surjective Means Outputs Cannot Repeat

Outputs may repeat in a surjective function.

The only requirement is that every codomain element is reached at least once.

5. Assuming the Horizontal-Line Test Checks Surjectivity

The horizontal-line test checks injectivity.

Surjectivity requires comparing the graph's range with the codomain.

6. Saying \(x^2\) Is Simply “Not Bijective” without Specifying Sets

The classification depends on the domain and codomain.

The mapping

\[ x^2:\mathbb{R}\to\mathbb{R} \]

is neither injective nor surjective, while

\[ x^2:[0,\infty)\to[0,\infty) \]

is bijective.

Practice

Classify a Finite Function

Let

\[ A=\{1,2,3\}, \qquad B=\{a,b,c\}, \]

and

\[ f=\{(1,b),(2,c),(3,a)\}. \]

Is \(f\) injective, surjective, or bijective?

Check Answer

Every input has a different output, so \(f\) is injective.

Every element of \(B\) is reached, so \(f\) is surjective.

Therefore,

\[ \boxed{f\text{ is bijective}.} \]

Find the Collision

Show that

\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=x^2-1 \]

is not injective.

Check Answer

For example,

\[ f(2)=4-1=3 \]

and

\[ f(-2)=4-1=3. \]

Because \(2\neq-2\), the function is not injective.

Test Surjectivity

Is

\[ f:\mathbb{R}\to\mathbb{R}, \qquad f(x)=x^3 \]

surjective?

Check Answer

Yes. For any

\[ y\in\mathbb{R}, \]

choose

\[ x=\sqrt[3]{y}. \]

Then

\[ f(x) = \left(\sqrt[3]{y}\right)^3 = y. \]

Therefore \(f\) is surjective.

Cardinality Reasoning

Suppose

\[ |A|=6 \]

and

\[ |B|=9. \]

Can a function \(f:A\to B\) be surjective?

Check Answer

No.

Six inputs cannot cover nine distinct codomain elements because each input has only one output.

For a surjective function between finite sets, we need

\[ |A|\geq|B|. \]

Change the Codomain

Consider

\[ f(x)=x^2. \]

Give a natural domain and codomain restriction that makes the function bijective.

Check Answer

One standard choice is

\[ \boxed{ f:[0,\infty)\to[0,\infty), \qquad f(x)=x^2. } \]

On nonnegative reals, squaring is both injective and surjective onto the nonnegative reals.

The Deeper Idea

Injective, surjective, and bijective behavior describes how completely a function organizes two sets.

An injective function preserves distinctions among inputs:

\[ \text{different inputs} \longrightarrow \text{different outputs}. \]

A surjective function covers its declared target:

\[ \text{every codomain element} \longleftarrow \text{at least one input}. \]

A bijection does both:

\[ \boxed{ \text{each domain element} \longleftrightarrow \text{exactly one codomain element} } \]

That is why bijections connect several major ideas at once:

What began as a simple question about arrows between sets becomes a general tool for comparing mathematical structures.

Summary

These three classifications tell us whether a function avoids collisions, covers its target, or establishes a perfect pairing. They are central to inverse functions, cardinality, transformations, and the structure of mathematical mappings.

Sets, Relations, and Functions