One to One Function — Definition, Graph, Examples

#Algebra
TL;DR
A one to one function is a function where no two different inputs ever share the same output, so distinct $x$-values always give distinct $y$-values. This article covers the injective definition, the horizontal line test, how to prove a function is one to one algebraically, why only these functions have inverses, and six worked examples.
BT
Bhanzu TeamLast updated on June 10, 202610 min read

What Is a One to One Function?

A one to one function is a function that sends distinct inputs to distinct outputs: if $x_1 \neq x_2$, then $f(x_1) \neq f(x_2)$. Equivalently — and this is the form you actually use in proofs — whenever two outputs are equal, the inputs must have been equal too: $f(x_1) = f(x_2) \implies x_1 = x_2$. The formal name is an injective function, or an injection.

Every input of any function already has exactly one output (that is what makes it a function at all). One to one adds a second restriction in the other direction: every output comes from exactly one input. A plain function can let many inputs share an output; a one to one function forbids it. The companion idea you will meet in the same chapter is the surjective (onto) function, which restricts the outputs instead.

How Do You Know if a Function Is One to One?

There are two standard tests — one visual, one algebraic — and they agree with each other.

The horizontal line test (visual). Look at the graph. If no horizontal line crosses it more than once, the function is one to one. A horizontal line at height $y = k$ marks every input that produces the output $k$; if it hits the curve twice, two inputs share that output, and one to one fails. This is the mirror image of the vertical line test, which checks whether something is a function in the first place.

The algebraic method (proof). Set $f(x_1) = f(x_2)$ and solve. If the algebra forces $x_1 = x_2$, the function is one to one. If you can reach a contradiction-free state where $x_1$ and $x_2$ differ — for example $x_1 = -x_2$ — it is not.

The two tests answer the same question from different angles: the graph shows you the collisions, the algebra proves there are none.

What Does a One to One Function Look Like? (The Graph)

A one to one graph never doubles back to the same height. Straight lines with non-zero slope qualify; so do cubics like $f(x) = x^3$ and exponentials like $f(x) = e^x$, because they climb (or fall) without ever flattening and returning. A parabola $f(x) = x^2$ fails — its two arms reach the same height on the left and right of the axis.

A function that always increases, or always decreases, is automatically one to one — it never revisits an output. That link to increasing and decreasing intervals is worth holding onto: strict monotonicity guarantees injectivity.

Why Only One to One Functions Have an Inverse

Here is the payoff. A function has an inverse if and only if it is one to one (on its given domain). An inverse $f^{-1}$ has to send each output back to the input it came from — and that only makes sense when there is exactly one such input. If $f(2) = f(-2) = 4$, then $f^{-1}(4)$ would have to be both $2$ and $-2$ at once, which no function can do.

This is why $f(x) = x^2$ has no inverse over all real numbers, but does once you restrict it to $x \geq 0$: restricting the domain throws away the duplicate arm and leaves a one to one piece. The square root is the inverse of that restricted half.

To find the inverse of a one to one function $f(x)$: swap $x$ and $y$, then solve for $y$. For $f(x) = 2x + 5$, writing $x = 2y + 5$ and solving gives $f^{-1}(x) = \dfrac{x - 5}{2}$.

Examples of One to One Function

The examples move from a quick algebraic check, through the most common sign-mistake, to inverses and a real-world coding map — the mix the strongest reference pages all demonstrate.

Example 1

Is $f(x) = 5x - 7$ one to one?

Set the outputs equal:

$$5x_1 - 7 = 5x_2 - 7.$$

Add $7$ to both sides, then divide by $5$: $x_1 = x_2$. The only way two outputs match is if the inputs already matched.

Final answer: yes, $f(x) = 5x - 7$ is one to one. Every line with non-zero slope is.

Example 2

A common slip — is $f(x) = x^2$ one to one over all real numbers?

Wrong attempt. A student sets $x_1^2 = x_2^2$, takes the square root of both sides, and writes $x_1 = x_2$, concluding the function is one to one. The step "square root both sides gives $x_1 = x_2$" feels automatic.

Test it against a number. $f(3) = 9$ and $f(-3) = 9$ — two different inputs, one output. So the conclusion has to be wrong somewhere.

Correct. Taking the square root of $x_1^2 = x_2^2$ gives $|x_1| = |x_2|$, which means $x_1 = x_2$ or $x_1 = -x_2$. That second option is the loophole: $3$ and $-3$ satisfy it.

Final answer: no, $f(x) = x^2$ is not one to one on $\mathbb{R}$. It only becomes one to one once restricted to $x \geq 0$.

Example 3

Is $f(x) = x^3$ one to one?

Set $x_1^3 = x_2^3$. The cube root is unique for every real number — unlike the square root, a cube has no sign ambiguity — so taking cube roots gives $x_1 = x_2$ with no second case.

Final answer: yes. The graph of $x^3$ never flattens and doubles back, so it also passes the horizontal line test.

Example 4

Is $f(x) = \dfrac{1}{x + 2}$, with $x \neq -2$, one to one?

Set the outputs equal:

$$\frac{1}{x_1 + 2} = \frac{1}{x_2 + 2}.$$

Cross-multiplying gives $x_2 + 2 = x_1 + 2$, so $x_1 = x_2$.

Final answer: yes, this rational function is one to one on its domain.

Example 5

Find the inverse of the one to one function $f(x) = 3x - 4$.

Write $y = 3x - 4$, swap the variables to get $x = 3y - 4$, then solve for $y$:

$$x + 4 = 3y \quad\Rightarrow\quad y = \frac{x + 4}{3}.$$

Final answer: $f^{-1}(x) = \dfrac{x + 4}{3}$. Check: $f^{-1}(f(2)) = f^{-1}(2) = 2$, so the inverse undoes $f$ exactly.

Example 6

A simple cipher shifts each letter forward by 3 positions ($A \to D$, $B \to E$, and so on, wrapping $Z \to C$). Is the cipher one to one, and why does that matter?

Each letter maps to a distinct shifted letter — no two letters collide on the same output. So the map is one to one, which means it has an inverse: shift back by $3$ to decode. A cipher that wasn't one to one would scramble two letters into one and could never be reliably decoded.

Final answer: yes — and being one to one is exactly what makes the message recoverable.

Where One to One Functions Earn Their Keep

"If two things produce the same signal, you can never tell them apart again."

The one to one idea was sharpened into modern form by the French collective writing under the name Nicolas Bourbaki in the mid-20th century, who fixed the words injection, surjection, and bijection so that mathematicians worldwide would mean the same thing by them. Before that, "one to one" was used loosely and often confused with "onto."

The property does real work far outside the textbook:

  • Cryptography and encoding. Any reversible code must be one to one — the shift cipher in Example 6 is the toy version of the bijections behind serious encryption. If encoding loses information, decoding is impossible.

  • Databases and identifiers. A primary key works because the map from record to ID is one to one — no two rows share an ID, so any ID retrieves exactly one row.

  • Inverse functions everywhere. Logarithms exist because $f(x) = e^x$ is one to one; arcsine exists only on the restricted interval where sine is one to one. Every "undo" operation in mathematics rests on injectivity.

Where Students Trip Up on One to One Functions

Mistake 1: Confusing "one to one" with "is a function"

Where it slips in: The reader runs the vertical line test, sees it pass, and concludes the function is one to one.

Don't do this: Treat the vertical and horizontal line tests as the same check. The vertical line test only confirms you have a function at all.

The correct way: Use the vertical line test for "is it a function," and the horizontal line test for "is it one to one." A parabola passes the first and fails the second.

Mistake 2: Mishandling the square root in the proof

Where it slips in: Proving injectivity for an even-power function and writing $x_1^2 = x_2^2 \implies x_1 = x_2$.

Don't do this: Take the square root of both sides as though it has a single result.

The correct way: $\sqrt{x_1^2} = |x_1|$, so $x_1^2 = x_2^2$ gives $x_1 = \pm x_2$. The negative branch is exactly the counterexample that breaks injectivity. The rusher skips straight to the positive root and misses it.

Mistake 3: Forgetting the domain matters

Where it slips in: Declaring $f(x) = x^2$ "not one to one" with no qualification.

Don't do this: Treat injectivity as a fixed property of a formula.

The correct way: Injectivity depends on the domain. $f(x) = x^2$ is not one to one on $\mathbb{R}$, but is one to one on $[0, \infty)$. Change the domain and the answer can change.

A real-world version of the mistake. When two distinct records collapse to the same identifier, the system can no longer tell them apart — the same failure as a non-injective function. Early hash-collision attacks on the MD5 algorithm exploited exactly this: researchers found two different inputs producing one identical hash, breaking the assumption that the map was effectively one to one and undermining every signature that relied on it.

Key Takeaways

  • A one to one function (injective function) sends distinct inputs to distinct outputs: $f(x_1) = f(x_2) \implies x_1 = x_2$.

  • The horizontal line test confirms it visually; setting $f(x_1) = f(x_2)$ and solving confirms it algebraically.

  • A function has an inverse if and only if it is one to one, which is why $x^2$ gains an inverse only when restricted to $x \geq 0$.

  • The most common error is confusing the horizontal line test (one to one) with the vertical line test (is a function).

  • Injectivity depends on the domain — the same formula can be one to one on one interval and not on another.

Practice These Before Moving On

  1. Use the algebraic method to decide whether $f(x) = 4x + 9$ is one to one.

  2. Decide whether $f(x) = |x|$ is one to one over all real numbers, and give a counterexample if not.

  3. Find the inverse of the one to one function $f(x) = \dfrac{x - 1}{2}$.

Answer to Question 1: $4x_1 + 9 = 4x_2 + 9 \Rightarrow x_1 = x_2$, so yes. Answer to Question 2: no — $|{-3}| = |3| = 3$, two inputs share an output. Answer to Question 3: $f^{-1}(x) = 2x + 1$. If Question 2 came out "yes," revisit Mistake 2 and check the negative branch.

Want a live Bhanzu trainer to walk through more one to one function problems? Book a free demo class — online globally.

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

Is a one to one function the same as an injective function?
Yes. "One to one" and "injective" are two names for the identical property — distinct inputs give distinct outputs.
Can a one to one function be onto as well?
Yes. A function that is both one to one and onto is called bijective, and a bijection is exactly the kind of function that has a true two-way inverse.
Is every linear function one to one?
Every linear function with a non-zero slope is one to one. The exception is a constant function like $f(x) = 5$, which sends every input to the same output and is as far from one to one as possible.
How is the horizontal line test different from the vertical line test?
The vertical line test checks whether a graph is a function (one output per input). The horizontal line test checks whether that function is one to one (one input per output). We covered the contrast in the testing section above.
Why does a function need to be one to one to have an inverse?
Because the inverse has to send each output back to a single input. If two inputs share an output, the inverse can't decide which one to return.
✍️ 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 →