Skip to main content
Mathovia

Algebra / Graphing and Functions

One-to-One Functions and the Horizontal Line Test

A function guarantees one output per input. A one-to-one function goes further: it guarantees one input per output as well, so nothing is ever reached twice. That extra condition is what makes a function reversible, which is why this idea sits directly in front of inverse functions. This lesson covers the definition, the horizontal line test, the algebraic proof, and how restricting a domain can make a function one-to-one when it was not.

Practice Problems
M
Written by
Mathovia Team
Editorial Team

Being a function means no input is ambiguous. Being one-to-one means no output is ambiguous either. That symmetry is the whole point, and it is what decides whether a function can be run backwards.

The one-to-one condition: different inputs always give different outputs
The one-to-one condition

The Definition

A function is one-to-one if different inputs always give different outputs:

The contrapositive is the version used in proofs, and it says the same thing:

Read that as: if two inputs land on the same output, they must have been the same input all along.

A mapping diagram with three inputs each going to its own distinct output, labelled one-to-one
Every output is used exactly once.

The word for this in higher mathematics is injective. The two terms mean exactly the same thing.

One-to-One vs Many-to-One

Every function is one or the other.

A mapping diagram where inputs negative 2 and 2 both point to the output 4, labelled not one-to-one
Two inputs sharing an output makes it many-to-one.
TypeDescriptionStill a function?
One-to-oneeach output used onceYes
Many-to-onesome output shared by several inputsYes
One-to-manyan input with several outputsNo — not a function at all

That third row is worth keeping straight. “One-to-many” is not a kind of function; it is the thing the vertical line test rules out. One-to-one and many-to-one are the only two options once you already have a function.

The Horizontal Line Test

The graphical test. Sweep a horizontal line up and down the graph.

  • Never crosses more than once → one-to-one.
  • Crosses twice anywhere → not one-to-one.
A cubic curve with a dashed horizontal line crossing it at exactly one point, labelled passes
A cubic: every horizontal line meets it once.

The reasoning mirrors the vertical test. A horizontal line is the set of all points at one particular height — one particular output. If it meets the curve twice, two different inputs produce that output.

A parabola with a dashed horizontal line crossing it at two points, labelled fails
A parabola fails: the same height is reached from both sides.

One failing line is enough. You do not need to check every height — a single horizontal line hitting twice settles it.

Order matters between the two tests: apply the vertical test first. A relation that is not a function cannot be one-to-one, because the term only applies to functions.

Which Familiar Functions Pass?

FunctionOne-to-one?Reason
, Yesa slanted line hits each height once
Noevery input gives the same output
No and share an output
Yesalways increasing
No and share an output
Yesincreasing on its whole domain
Yeseach output comes from one input
Yesalways increasing

A useful shortcut: a function that is always increasing, or always decreasing, is automatically one-to-one. It can never come back to a height it has already used. Turning points are what break the property, which is why the parabola and absolute value fail — both double back.

Proving It Algebraically

The graph is convincing but not a proof. The algebraic method is short and always works the same way.

Method. Assume , then show .

Example — prove is one-to-one.

Since equal outputs force equal inputs, it is one-to-one.

To prove a function is not one-to-one, a single counterexample is enough. For : and with . Done — no general argument required.

That asymmetry is worth remembering. Proving yes needs a general argument; proving no needs one pair of numbers.

Restricting the Domain

A function that fails can often be repaired by throwing away part of its domain.

is not one-to-one on all real numbers. Restrict it to and it becomes one-to-one — the left arm of the parabola, which was causing the duplication, is simply removed.

This is not a trick; it is standard practice. It is exactly how is defined as a function, and how the inverse trigonometric functions are defined later on. The cost is that you are now working with a different, smaller function.

Why It Matters: Inverses

Here is the payoff. Reversing a function means swapping every input and output. For the reversal to be a function, each output must have come from exactly one input — which is precisely the one-to-one condition.

Reverse and the pair becomes while becomes . The input 9 now has two outputs, so the reversal fails the one-output rule.

A function has an inverse function if and only if it is one-to-one. See Inverse Functions for what to do with that.

Worked Example A: From a Graph

A graph passes the vertical line test and is always rising. Is it one-to-one?

Yes. A strictly increasing function never revisits an output, so no horizontal line can cross it twice.

Worked Example B: A Proof

Prove is one-to-one.

Worked Example C: A Counterexample

Show is not one-to-one.

Try the two values either side of the vertex at :

Two inputs, one output. Not one-to-one.

Worked Example D: A Rational Function

Is one-to-one?

Yes. Each branch is decreasing and they occupy different output ranges, so no height is repeated.

Worked Example E: Restricting

Find a restriction making one-to-one.

The vertex is at , so restrict to (or ). Either half passes the horizontal line test; the convention is to keep the right-hand branch.

Common Mistakes to Avoid

  • Using the vertical test for one-to-one. That test only decides whether it is a function.
  • Applying the horizontal test before the vertical one. A non-function cannot be one-to-one.
  • Thinking many-to-one means “not a function”. It is a perfectly good function.
  • Confusing one-to-many with many-to-one. One-to-many is not a function at all.
  • Trying to prove “not one-to-one” in general. One counterexample is sufficient and much faster.
  • Checking only a couple of horizontal lines. Passing a few proves nothing; use algebra or the increasing/decreasing argument.
  • Forgetting the restricted domain afterwards. Once restricted, it is a different function.

Where This Leads Next

  • Inverse functions — the direct payoff, since one-to-one is the entry condition.
  • Inverse trigonometric functions, all defined on restricted domains for exactly this reason.
  • Logarithms, the inverse of the one-to-one exponential function.
  • Bijections and injections, the formal vocabulary in later courses.
  • Cryptography and hashing, where whether a mapping is reversible is the entire question.

Practice Problems

Work each one before opening the answer.

Problem 1. Is one-to-one?

Show answer

Yes. .

Problem 2. Is one-to-one?

Show answer

No. .

Problem 3. Is one-to-one?

Show answer

Yes — a cubic of this form is always increasing, so it passes the horizontal line test.

Problem 4. Is one-to-one?

Show answer

No. and .

Problem 5. Is the constant function one-to-one?

Show answer

No. Every input gives 6, so outputs are shared endlessly.

Problem 6. Prove is one-to-one.

Show answer

.

Problem 7. Give a counterexample showing is not one-to-one.

Show answer

and .

Problem 8. What restriction makes one-to-one?

Show answer

The vertex is at , so restrict to or .

Problem 9. A graph fails the horizontal line test but passes the vertical one. What can you say?

Show answer

It is a function, but many-to-one, so it has no inverse function unless the domain is restricted.

Problem 10. Does have an inverse function?

Show answer

Yes. It is always increasing, hence one-to-one. Its inverse is the logarithm.

Quick Reference

QuestionAnswer
DefinitionDifferent inputs give different outputs
Proof form
DisproofOne counterexample pair
Graphical testHorizontal line test
Vertical line testDecides “is it a function”
Horizontal line testDecides “is it one-to-one”
Always increasing/decreasingAutomatically one-to-one
Turning point presentNot one-to-one
Other nameInjective
Why it mattersOnly these have inverse functions

One-to-one is the condition that makes inverse functions possible. It builds on the definition of a function, and restricting the domain is the standard way to obtain it. More Algebra lessons are available.

Frequently Asked Questions

What is a one-to-one function?+

A function is one-to-one when every output comes from exactly one input. Different inputs always produce different outputs, so no value in the range is ever hit twice. It is also called an injective function.

What is the horizontal line test?+

Draw horizontal lines across the graph. If any of them crosses the curve more than once, the function is not one-to-one, because that output height is being reached from two different inputs.

What is the difference between the vertical and horizontal line tests?+

The vertical line test decides whether a graph is a function at all. The horizontal line test decides whether that function is one-to-one. A graph must pass the vertical test first for the horizontal test to be meaningful.

How do you prove a function is one-to-one algebraically?+

Assume and show this forces . For : if then , so , which proves it is one-to-one.

Why do one-to-one functions matter?+

Only a one-to-one function has an inverse that is also a function. Reversing a many-to-one function would send one input to several outputs, breaking the definition of a function.

Is x squared a one-to-one function?+

No. and , so two different inputs give the same output, and a horizontal line at crosses the parabola twice. Restricting the domain to does make it one-to-one.

Related lessons