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:
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.
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).
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:
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.
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|.
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).
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):
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:
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}.
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:
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.
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.
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
-
"One-one means each input has one output." No — every function has that property. One-one means each output has at most one input. The name "one-one" refers to the one-to-one correspondence between inputs and outputs, not the basic function rule.
-
"Onto depends only on the function rule." It also depends on the codomain. The function f(x) = x^2 is onto from \mathbb{R} to [0, \infty) but not onto from \mathbb{R} to \mathbb{R}. Always check which codomain is declared.
-
"A bijection must be between sets of the same size." For finite sets, yes — |A| = |B|. For infinite sets, the statement is more subtle. The function f(n) = 2n from \mathbb{N} to the even natural numbers is a bijection, even though the even numbers are a proper subset of \mathbb{N}. Infinite sets can be bijected with proper subsets of themselves — this is one of the defining oddities of infinity.
-
"If a function fails the horizontal line test, it has no inverse." More precisely: it has no inverse with the full domain and codomain as given. You can always restrict the domain to make it one-one and restrict the codomain to make it onto. For f(x) = x^2, the standard restriction is f: [0, \infty) \to [0, \infty), and the inverse is f^{-1}(x) = \sqrt{x}.
-
"Many-one and into are separate types." They are separate properties. A function can be many-one (fails one-one) without being into (it could still be onto), or into (fails onto) without being many-one (it could still be one-one). "Many-one into" means both properties fail simultaneously.
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:
- Total functions: n^m (each of m inputs has n choices).
- Injections: n \cdot (n-1) \cdot (n-2) \cdots (n - m + 1) = \frac{n!}{(n-m)!} if m \le n, and 0 if m > n. The first input has n choices, the second has n - 1 (cannot collide with the first), and so on. This is the permutation formula P(n, m).
- Bijections: exist only when m = n, and the count is n! = n \cdot (n-1) \cdots 2 \cdot 1.
- Surjections: harder to count; the formula involves inclusion-exclusion and is called the Stirling number of the second kind (times 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.
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.
- Composition of Functions — what happens when you feed the output of one function into another, and how the types interact.
- Inverse of a Function — only bijections have full inverses; this article shows how to find them and what to do when the function is not bijective.
- Functions — Definition and Notation — the foundation this article builds on.
- Sets — Introduction — the set operations that underlie domain and codomain.
- Ways to Define Functions — the four methods of specifying a function, each of which can produce any of the four types.