Injective Function — How to Prove It, and Examples

#Algebra
TL;DR
An injective function (also called a one-one function) is one where distinct inputs always produce distinct outputs — no two domain elements share the same image. This article gives the formal definition, the algebraic proof method, the horizontal line test, the injective-vs-surjective contrast, the counting formula, and six worked examples
BT
Bhanzu TeamLast updated on July 1, 20267 min read

What Is An Injective Function?

An injective function $f: A \to B$ is one where distinct inputs map to distinct outputs. Said the way it's usually proved: if $f(a) = f(b)$, then $a = b$. The everyday name is a one-one function (or "one-to-one"), and the one-to-one function article approaches the same idea through graphs and tables if you want a second angle.

Two equivalent ways to say the same thing:

  • Forward form: $a \neq b \implies f(a) \neq f(b)$ (different inputs can't collide).

  • Contrapositive form: $f(a) = f(b) \implies a = b$ (a shared output forces the inputs to be equal).

The contrapositive form is the one you actually use in proofs, because it gives you an equation to solve.

How Do You Prove A Function Is Injective?

A frequent search is how do I prove a function is one-one? There are two standard routes — one algebraic, one graphical.

The algebraic method (works for any function with a formula):

  1. Assume $f(a) = f(b)$.

  2. Write out the equation and simplify.

  3. If every legal simplification forces $a = b$, the function is injective.

The horizontal line test (works when you have a graph): a function is injective exactly when no horizontal line crosses its graph more than once. If any horizontal line hits the curve twice, two different inputs share that output, and one-one fails.

What Is The Difference Between Injective And Surjective?

This disambiguation is the highest-frequency related query, so it gets answered directly. The two properties guard opposite doors:

  • Injective (one-one): no output is shared. Distinct inputs give distinct outputs. Some outputs may go unused.

  • Surjective (onto): every output is used. No element of the codomain is left out. Sharing is allowed.

They are independent — a function can be one without the other. $f(x) = e^x$ on $\mathbb{R} \to \mathbb{R}$ is injective (no two inputs share a value) but not surjective (negatives are never outputs). A function that is both is a bijective function, and only those have inverses. For the onto side in full, see the surjective function article.

What Is The Number Of Injective Functions Between Two Finite Sets?

If $A$ has $m$ elements and $B$ has $n$ elements with $n \geq m$, the number of injective functions from $A$ to $B$ is the falling factorial:

$$n \times (n-1) \times (n-2) \times \cdots \times (n - m + 1) = \frac{n!}{(n-m)!}$$

Each symbol: $m$ is the domain size, $n$ the codomain size. The first input has $n$ choices of output, the second has $n-1$ left (one is taken), the third $n-2$, and so on. If $m > n$, the count is 0 — there aren't enough distinct outputs to go around, a direct consequence of the pigeonhole principle.

Examples Of Injective Functions

The six examples below build from a small finite check to a proof and a counting problem, with one deliberate wrong turn.

Example 1

Decide whether $f: {1, 2, 3} \to {p, q, r, s}$ given by $f(1)=p,\ f(2)=q,\ f(3)=r$ is injective.

Compare the three outputs.

$p$, $q$, $r$ are all different.

No two inputs share an output, so the function is injective. (Output $s$ goes unused, which is fine for one-one.)

Example 2

Decide whether $f: \mathbb{R} \to \mathbb{R}$, $f(x) = x^2$, is injective.

The tempting move is to say "$x^2$ is a clean, familiar formula, so it must be one-one."

Test the definition. Suppose $f(a) = f(b)$.

$a^2 = b^2$.

This gives $a = b$ or $a = -b$.

So $f(2) = 4$ and $f(-2) = 4$ — two different inputs, same output.

The function is not injective. The "familiar formula must be one-one" instinct skipped the negative root. The fix is to restrict the domain to $[0, \infty)$, where $a^2 = b^2$ does force $a = b$. The first instinct to drop the negative case is exactly where this one breaks.

Example 3

Prove that $f: \mathbb{R} \to \mathbb{R}$, $f(x) = 5x - 7$, is injective.

Assume $f(a) = f(b)$.

$5a - 7 = 5b - 7$.

$5a = 5b$.

$a = b$.

The equality forces $a = b$, so $f$ is injective.

Example 4

Decide whether $f: \mathbb{R} \to \mathbb{R}$, $f(x) = x^3$, is injective.

Assume $f(a) = f(b)$.

$a^3 = b^3$.

Taking real cube roots, $a = b$ (a real number has exactly one real cube root).

So $f$ is injective — and unlike $x^2$, no negative-root trap appears, because cubing preserves sign.

Example 5

Decide whether $f: \mathbb{R} \to \mathbb{R}$, $f(x) = \dfrac{1}{x+1}$ (domain $x \neq -1$), is injective.

Assume $f(a) = f(b)$.

$\dfrac{1}{a+1} = \dfrac{1}{b+1}$.

Cross-multiplying: $b + 1 = a + 1$.

$a = b$.

So $f$ is injective on its domain.

Example 6

Count the injective functions from a 2-element set to a 4-element set.

Here $m = 2$, $n = 4$.

$$\frac{n!}{(n-m)!} = \frac{4!}{2!} = \frac{24}{2} = 12$$

There are 12 injective functions. (The first input picks any of 4 outputs; the second picks any of the remaining 3, giving $4 \times 3 = 12$.)

Why One-One Matters: "Injectivity Is What Makes Reversal Possible"

Injectivity exists because mathematics needed a way to guarantee a process can be undone without ambiguity.

  • It is half of invertibility. A function can be reversed only if each output traces back to exactly one input. If two inputs share an output, the reverse map can't decide which one to return. This is the backbone of every inverse function.

  • It underwrites encoding. Lossless compression, primary keys in a database, and serial numbers all depend on a one-one assignment — distinct items must get distinct codes, or information is lost.

  • It compares set sizes. An injection from $A$ into $B$ proves $B$ is at least as large as $A$, the tool behind formal arguments about infinite sets.

The destination this opens up is the comparison of infinities. Georg Cantor (1845–1918, Germany) built his entire theory of cardinality on injective and surjective maps, proving the reals cannot be put in one-one correspondence with the integers.

Where Injectivity Slips Away

Three mistakes account for most wrong "is it one-one?" answers.

Mistake 1: Forgetting the negative root

Where it slips in: any even power or absolute-value function.

Don't do this: declare $f(x) = x^2$ injective because the formula looks simple.

The correct way: test $f(a) = f(b)$ fully. $a^2 = b^2$ allows $a = -b$, so $2$ and $-2$ collide. Even functions are never one-one on a domain symmetric about zero. The rusher who solves $a^2 = b^2$ as just $a = b$ misses the second root.

Mistake 2: Confusing one-one with onto

Where it slips in: problems that mention "every output" or "covers the codomain."

Don't do this: call a function not-injective because some output is unused.

The correct way: unused outputs are irrelevant to injectivity — that's a surjectivity concern. Injective asks only whether any output is shared. The second-guesser who keeps checking coverage when the question is about collisions wastes the effort here.

Mistake 3: Treating $f^{-1}$ as a reciprocal

Where it slips in: the moment inverse notation appears.

Don't do this: read $f^{-1}(x)$ as $\dfrac{1}{f(x)}$.

The correct way: $f^{-1}$ is the reverse map, defined only because $f$ is one-one. It has nothing to do with reciprocals. The reciprocal $\dfrac{1}{\sin\theta}$ and the inverse $\sin^{-1}\theta$ get read as the same thing, and that swap is a steady source of wrong answers.

Conclusion

  • An injective function sends distinct inputs to distinct outputs — no two inputs share an image.

  • Prove it algebraically (assume $f(a)=f(b)$, force $a=b$) or graphically (the horizontal line test).

  • Injective and surjective are independent: one forbids collisions, the other demands full coverage.

  • The number of injective functions from an $m$-set to an $n$-set is $\dfrac{n!}{(n-m)!}$ when $n \geq m$, and $0$ otherwise.

  • Injectivity is half of what a function needs to be invertible.

To build this with a teacher who teaches the reasoning first, explore Bhanzu's algebra tutor, find help with algebra, or browse math tutoring. Want a live Bhanzu trainer to walk through one-one proofs with your child? Book a free demo class.

Read More

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

Is an injective function the same as a one-one function?
Yes. "Injective" and "one-one" (or "one-to-one") name the same property: distinct inputs give distinct outputs.
Can an injective function have unused outputs?
Yes. Injectivity only forbids shared outputs; it says nothing about whether every output is reached. A function with unused outputs can still be perfectly one-one
How do you prove a function is not injective?
Find two different inputs with the same output. A single collision — like $f(2) = f(-2)$ for $f(x)=x^2$ — is enough.
Is every straight-line function injective?
A non-horizontal line $f(x) = ax + b$ with $a \neq 0$ is injective. A horizontal line ($a = 0$) sends every input to the same output, so it is not.
Does an injective function always have an inverse?
It has an inverse onto its range. For a full inverse onto a chosen codomain, it must also be onto — that is, bijective.
✍️ Written By
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →