In short

A function f: A \to B is one-one (injective) if different inputs always produce different outputs. It is onto (surjective) if every element of the codomain B is actually an output. It is bijective if it is both one-one and onto — a perfect pairing between A and B with no collisions and no gaps. A function that is not one-one is called many-one (some outputs are shared), and one that is not onto is called into (some elements of B are never hit). These four labels determine whether a function has an inverse, and if so, what kind.

Imagine a classroom of 30 students taking a test. The function f assigns each student their score out of 100. Two things can happen that make this function interesting — or problematic.

First: two students might get the same score. Priya and Rahul both score 87. The function sends two different inputs to the same output. This is allowed (it is still a valid function), but it means you cannot reverse the process — if someone tells you "the score was 87," you cannot determine whether it was Priya or Rahul. The function is not one-one.

Second: maybe no student scored 23. The number 23 is in the codomain (scores from 0 to 100), but it is not in the range (no student actually got that score). The function does not cover all of B. It is not onto.

These two questions — "do different inputs always give different outputs?" and "is every potential output actually achieved?" — classify every function into one of four types. The classification is not just labelling for its own sake. Whether a function is one-one or onto determines whether it can be reversed, and reversibility is the key to solving equations.

One-one (injective)

One-one (injective) function

A function f: A \to B is one-one (or injective) if no two distinct elements of A map to the same element of B:

\text{For all } a_1, a_2 \in A, \quad f(a_1) = f(a_2) \implies a_1 = a_2

Equivalently: a_1 \neq a_2 \implies f(a_1) \neq f(a_2).

In an arrow diagram, one-one means no element of B has more than one arrow pointing to it. Every output has at most one source.

Take f: \{1, 2, 3\} \to \{a, b, c, d\} defined by f(1) = b, f(2) = d, f(3) = a. Each element of B that is hit is hit by exactly one arrow. This is one-one.

Take g: \{1, 2, 3\} \to \{a, b, c\} defined by g(1) = a, g(2) = a, g(3) = c. Here g(1) = g(2) = a — two distinct inputs share the same output. This is not one-one.

Two arrow diagrams comparing a one-one function with a many-one functionTwo pairs of ovals side by side. The left pair shows f: 1 maps to b, 2 maps to d, 3 maps to a. No element of B has more than one arrow. The right pair shows g: 1 maps to a, 2 maps to a, 3 maps to c. Element a in B has two arrows pointing to it. f : one-one A B 1 2 3 a b c d g : not one-one (many-one) A B 1 2 3 a b c each output has ≤ 1 arrow output a has 2 arrows
Left: the function $f$ is one-one — every element of $B$ that receives an arrow receives exactly one. Right: the function $g$ is many-one — two arrows land on $a$, so $g$ is not injective.

For real-valued functions, one-one has a graphical test: the horizontal line test. If every horizontal line intersects the graph at most once, the function is one-one. The function f(x) = x^3 passes (strictly increasing, never doubles back). The function f(x) = x^2 fails (the horizontal line y = 4 hits the graph at x = 2 and x = -2).

Horizontal line test comparing x cubed and x squaredTwo graphs side by side. The left graph shows y equals x cubed, a strictly increasing curve. A horizontal dashed line at y equals 4 hits the curve at exactly one point, so it passes the horizontal line test. The right graph shows y equals x squared. A horizontal dashed line at y equals 4 hits the curve at two points, x equals 2 and x equals negative 2, so it fails. x y y = x³ (passes) x y y = x² (fails)
Left: $y = x^3$ is one-one — every horizontal line hits the curve once. Right: $y = x^2$ is many-one — the line $y = 4$ hits at two points, so two different inputs produce the same output.

Onto (surjective)

Onto (surjective) function

A function f: A \to B is onto (or surjective) if every element of B is the image of at least one element of A:

\text{For every } b \in B, \quad \text{there exists } a \in A \text{ such that } f(a) = b

Equivalently: the range of f equals the codomain B.

In the arrow diagram, onto means every element of B has at least one arrow pointing to it. No element of the codomain is left unreached.

Take f: \{1, 2, 3, 4\} \to \{x, y\} defined by f(1) = x, f(2) = y, f(3) = x, f(4) = y. Every element of B = \{x, y\} is hit. This is onto.

Take g: \{1, 2\} \to \{a, b, c\} defined by g(1) = a, g(2) = b. The element c in B has no arrow. The range is \{a, b\}, which is a proper subset of B = \{a, b, c\}. This is not onto — it is called into.

Two arrow diagrams comparing an onto function with an into functionTwo pairs of ovals. The left pair shows f mapping 1 to x, 2 to y, 3 to x, 4 to y. Both x and y have arrows, so f is onto. The right pair shows g mapping 1 to a and 2 to b. Element c in B has no arrow, so g is not onto. f : onto A B 1 2 3 4 x y g : not onto (into) A B 1 2 a b c every element of B has ≥ 1 arrow element c has 0 arrows
Left: the function $f$ is onto — both elements of $B$ receive arrows. Right: the function $g$ is into — the element $c$ receives no arrow, so the range $\{a, b\}$ is a proper subset of the codomain $\{a, b, c\}$.

Whether a function is onto depends on the codomain you declare. The function f(x) = x^2 from \mathbb{R} to \mathbb{R} is not onto, because no real input maps to a negative output — the range is [0, \infty), not all of \mathbb{R}. But the same rule f(x) = x^2 from \mathbb{R} to [0, \infty) is onto, because now the codomain matches the range. The function itself did not change; the codomain did.

Bijective

Bijective function

A function f: A \to B is bijective if it is both one-one and onto. Every element of B has exactly one element of A mapping to it — no more, no less.

A bijection is a perfect pairing. Each element of A is matched with a unique element of B, and every element of B is matched. No collisions, no gaps. If A and B are finite, this means |A| = |B|.

Arrow diagram of a bijective function between two three-element setsTwo ovals of equal size. The left oval A contains 1, 2, 3. The right oval B contains p, q, r. One arrow goes from each element of A to a distinct element of B, forming a perfect one-to-one matching: 1 to q, 2 to r, 3 to p. A B 1 2 3 p q r bijective: each element of B has exactly 1 arrow
A bijection between $A = \{1, 2, 3\}$ and $B = \{p, q, r\}$. Each element of $A$ maps to a unique element of $B$, and every element of $B$ is hit. The arrows form a perfect one-to-one pairing.

The crucial property of a bijection: it is invertible. You can reverse every arrow. If f(1) = q, then f^{-1}(q) = 1. The inverse function f^{-1}: B \to A is well-defined precisely because no two inputs share an output (one-one) and every element of B has a preimage (onto). Without either condition, the reversal breaks.

The four-way classification

Every function f: A \to B falls into exactly one of four categories:

Type One-one? Onto? Arrow pattern
One-one and onto (bijection) Yes Yes Perfect pairing
One-one but not onto (injection, into) Yes No No collisions, but some of B unused
Not one-one but onto (surjection, many-one onto) No Yes Collisions, but all of B covered
Not one-one and not onto (many-one into) No No Collisions, and some of B unused

The function f(x) = x^2 from \mathbb{R} to \mathbb{R} is many-one into: it is not one-one (f(3) = f(-3) = 9) and not onto (negative numbers are never outputs). The function f(x) = x^3 from \mathbb{R} to \mathbb{R} is a bijection: it is one-one (strictly increasing) and onto (every real number is a perfect cube of some real number).

Four types of functions shown as schematic arrow diagramsFour small arrow diagrams in a row. The first shows a bijection with perfect pairing. The second shows one-one into with an unused element in B. The third shows many-one onto with two arrows landing on one element of B. The fourth shows many-one into with both collisions and unused elements. bijection 1-1, onto one-one into 1-1, not onto many-one onto not 1-1, onto many-one into not 1-1, not onto every function falls into exactly one of these four types
The four types. A bijection has perfect pairing. One-one into has no collisions but leaves gaps. Many-one onto has collisions but covers everything. Many-one into has both collisions and gaps.

How to test: the algebraic method

For functions defined by formulae on \mathbb{R}, here are the standard algebraic tests.

Testing one-one. Assume f(a_1) = f(a_2) and check whether this forces a_1 = a_2. If it does, the function is one-one. If you can find a counterexample (two distinct inputs with the same output), it is not.

Testing onto. Pick an arbitrary b \in B and try to solve f(a) = b for a in terms of b. If a solution exists in A for every b \in B, the function is onto.

Two worked examples

Example 1: Classify $f: \mathbb{R} \to \mathbb{R}$ defined by $f(x) = 3x + 5$

Step 1. Test one-one. Suppose f(a_1) = f(a_2):

3a_1 + 5 = 3a_2 + 5 \implies 3a_1 = 3a_2 \implies a_1 = a_2

So f is one-one.

Why: the implication chain is airtight — equal outputs force equal inputs. No exceptions, no special cases.

Step 2. Test onto. Take any b \in \mathbb{R} and solve 3x + 5 = b:

x = \frac{b - 5}{3}

This is a real number for every real b, so for every element of the codomain, there is a preimage.

Why: the solution x = (b - 5)/3 is always defined and always real, so every b is hit.

Step 3. Since f is both one-one and onto, it is bijective.

Step 4. The inverse is f^{-1}(b) = \frac{b - 5}{3}.

Result: f(x) = 3x + 5 is a bijection from \mathbb{R} to \mathbb{R}.

Graph of f of x equals 3x plus 5 showing a straight line with positive slopeA straight line with slope 3 and y-intercept 5 is drawn on the x-y plane. A horizontal dashed line at y equals 2 hits the line at exactly one point, illustrating that the function is one-one. The line extends upward and downward without bound, illustrating that it is onto. x y 1 2 −1 5 one hit f(x) = 3x + 5
The graph of $f(x) = 3x + 5$: a straight line with slope $3$. Every horizontal line hits the graph exactly once (one-one), and the graph extends to all $y$-values (onto). The function is a bijection.

The graph tells the whole story: a non-horizontal straight line is always bijective from \mathbb{R} to \mathbb{R}, because its slope is constant and non-zero, ensuring both the horizontal line test and full coverage of the y-axis.

Example 2: Classify $f: \mathbb{R} \to \mathbb{R}$ defined by $f(x) = x^2 - 4x + 3$

Step 1. Test one-one. Try two specific inputs:

f(1) = 1 - 4 + 3 = 0, \qquad f(3) = 9 - 12 + 3 = 0

Two distinct inputs (1 and 3) give the same output (0). So f is not one-one — it is many-one.

Why: a single counterexample is enough to kill injectivity. You do not need to find all collisions; one pair suffices.

Step 2. Rewrite in vertex form to understand the range.

f(x) = x^2 - 4x + 3 = (x - 2)^2 - 1

The minimum value of (x - 2)^2 is 0 (at x = 2), so the minimum value of f(x) is -1. The range is [-1, \infty).

Why: completing the square reveals the vertex of the parabola at (2, -1). Since the parabola opens upward (a = 1 > 0), -1 is the minimum output value.

Step 3. Test onto. The codomain is \mathbb{R}, but the range is [-1, \infty). Since [-1, \infty) \neq \mathbb{R} (for example, -5 is not in the range), f is not onto.

Step 4. Classification: f is many-one into. It is neither one-one nor onto.

Result: f(x) = x^2 - 4x + 3 from \mathbb{R} to \mathbb{R} is many-one into.

Graph of f of x equals x squared minus 4x plus 3 showing it is many-one intoAn upward-opening parabola with vertex at (2, negative 1). The parabola crosses the x-axis at x equals 1 and x equals 3. A horizontal dashed line at y equals 0 hits the parabola at two points, showing the function is many-one. A horizontal dashed line at y equals negative 5 misses the parabola entirely, showing the function is not onto. x y 1 2 3 4 −1 f(1) = 0 f(3) = 0 vertex (2, −1) range = [−1, ∞) ≠ ℝ
The parabola $f(x) = (x-2)^2 - 1$ with vertex at $(2, -1)$. The horizontal line $y = 0$ hits the parabola at two points ($x = 1$ and $x = 3$), proving it is many-one. The parabola never dips below $y = -1$, so it is not onto (as a function to $\mathbb{R}$).

If you changed the codomain to [-1, \infty), the function would become onto. If you also restricted the domain to [2, \infty) (only the right half of the parabola), it would become one-one as well. With both changes, f: [2, \infty) \to [-1, \infty) would be a bijection. Restricting domain and codomain is how you manufacture invertibility from a function that does not naturally have it.

Common confusions

Going deeper

If you can classify any given function as one-one, onto, both, or neither, and you understand the connection between bijectivity and invertibility, you have the tools for the next several chapters. The rest of this section explores counting and structural consequences.

Counting injections, surjections, and bijections

For finite sets with |A| = m and |B| = n:

For A = \{1, 2, 3\} and B = \{a, b, c\}: total functions = 3^3 = 27, injections = 3! = 6, bijections = 3! = 6 (same as injections here, since |A| = |B|), surjections = 6.

Why bijections matter

A bijection f: A \to B says that A and B have "the same structure" in terms of size. For finite sets, this is obvious: both have the same number of elements. For infinite sets, this is how mathematicians define "same size" — two infinite sets have the same cardinality if there exists a bijection between them. This definition, due to Cantor, led to the stunning discovery that \mathbb{R} is "larger" than \mathbb{N} — there is no bijection between the two, even though both are infinite. That story belongs to the study of set theory, but the seed of it is right here: bijectivity is the mathematical way to measure size.

Interactive: testing injectivity

Drag the red point along the parabola below. A horizontal dashed line tracks the point's y-value. When the line hits the curve at a second point, the function fails the horizontal line test at that height — it is not one-one there.

Interactive horizontal line test on y equals x squaredThe parabola y equals x squared with a draggable red point. A horizontal dashed line extends from the point across the graph. When the point is above y equals 0, the line hits the parabola at a second point on the opposite side, showing the function is not one-one. x y −1 1 2 drag the red point
Drag the point on $y = x^2$. For any position above the $x$-axis, notice that a horizontal line at that height would hit the curve at a mirror-image point on the other side — two inputs share the same output. That is why $x^2$ is not one-one on $\mathbb{R}$.

Where this leads next

You now know how to classify any function as one-one, onto, both, or neither. The next articles use this classification.