Not sure which lesson to do first? Find your level and get a plan →

Math · Advanced Functions · Grade 9-12

Horizontal Line Test

The horizontal line test checks whether a function is one-to-one: if every horizontal line crosses the graph at most once, no two inputs share an output, so an inverse exists.


Quick Answer

The horizontal line test checks whether a function is one-to-one: if every horizontal line crosses the graph at most once, no two inputs share an output, so an inverse exists. Use it on a graph to decide quickly whether a function has an inverse on its whole domain: y=x3 and y=2x pass, while y=x2 fails at height 4, which it reaches at both x=2 and x=−2. A horizontal line that misses the graph entirely is fine. When a function fails, you can often restrict its domain to a piece that passes.

Why This Matters

An inverse function has to send each output back to a single input, and this test shows at a glance whether that is possible. It explains why x means only the positive root and why arcsin⁡ returns just one angle. Skipping it produces "inverses" that are not functions at all, such as the sideways parabola you get by reflecting y=x2 across y=x.

Intuitive Explanation

Graph f(x)=x2 and slide a ruler, held horizontally, up the page. At height 4 the ruler touches the parabola twice, at (−2,4) and (2,4): two different inputs with the same output. If someone tells you only that the output was 4, you cannot say which input produced it, and that is exactly what an inverse would have to do. Slide the ruler up y=x3 instead: it never touches more than once, because the curve keeps rising, so every output traces back to one input.

Any function that only increases or only decreases passes: 2x, ln⁡x, −3x+1, x. Functions that turn around fail: parabolas, ∣x∣, sin⁡x and cos⁡x. When you have a formula but no graph, the algebraic version of the test is to check whether f(a)=f(b) forces a=b. For f(x)=3x+5, the equation 3a+5=3b+5 gives a=b, so the function is one-to-one.

The vertical line test looks similar but answers a different question. Vertical lines check whether a graph is a function at all, one output for each input; horizontal lines check whether a function is one-to-one, one input for each output. A circle fails the vertical test; y=x2 passes the vertical test but fails the horizontal one; y=x3 passes both. When a graph passes both, its reflection across y=x is a function too: the inverse.

Think of it like this. The test works like a cloakroom: each ticket number must belong to only one coat, or the attendant cannot hand back the right one. A horizontal line at height y asks how many coats carry ticket y. More than one breaks the system; a ticket number nobody holds causes no trouble.

Core idea. If no horizontal line hits the graph more than once, the function is one-to-one and invertible.


When to Use

Use the test when you are asked whether a function has an inverse, whether it is one-to-one, or whether an equation f(x)=c can have more than one solution, especially when the graph is in front of you. If the function fails, look for a restricted domain on which it only rises or only falls. To decide whether a curve is a function in the first place, use the vertical line test; for a formula with no graph, check whether f(a)=f(b) forces a=b.

Tip. Ask: Does every horizontal line cross the graph at most once?

How to Recognize It

Before drawing horizontal lines, check what you are asked to decide: whether a graph is a function at all, or whether a function can be run backwards.

  1. Are you deciding whether the graph is a function in the first place?

    If yes, use vertical lines: each must cross at most once, so every input has one output. The horizontal line test assumes you already have a function and asks the reverse, whether every output comes from one input.

  2. Does the graph turn around anywhere, with a peak, a valley or a U-shape?

    If yes, it fails, since a height near the turn is reached once going up and again coming down: y=x3−3x reaches y=0 at three inputs. A graph that only rises or only falls, like y=2x, always passes.

  3. Is there only a formula and no graph?

    If yes, use algebra: suppose f(a)=f(b) and see whether that forces a=b. For 5x−2, 5a−2=5b−2 gives a=b, so it is one-to-one, while for x2, a2=b2 lets b=−a.

  4. Does the function fail, but you still need an inverse?

    If yes, restrict the domain to a stretch where the graph only rises or only falls, then test again: y=x2 for x≤0 passes, with inverse y=−x. Failing on the full domain only rules out an inverse there.

Horizontal Line Test compared with Vertical line test, One-to-one (injective), and Restricted domain

These rows all concern how inputs and outputs pair up, and two of them are tests drawn with straight lines. Ask whether you are checking for one output per input, for one input per output, naming the property itself, or repairing a failure.

Horizontal Line Test

Meaning
Use this when you have a function's graph and need to decide whether it is one-to-one and therefore has an inverse.
Key test
Does every horizontal line cross the graph at most once?
Example
Does f(x)=x3 pass the horizontal line test?

Vertical line test

Meaning
Checks whether a graph is a function at all (one output per input), not whether it is one-to-one.
Key test
Use to decide if a relation is even a function.
Example
A circle fails the vertical line test

One-to-one (injective)

Meaning
The property the test detects; the test is the visual method, the property is the conclusion.
Key test
Use the algebraic definition (f(a)=f(b)⇒a=b) when no graph is available.
Formula
f(a)=f(b)⇒a=b
Example
f(x)=2x+1 is one-to-one

Restricted domain

Meaning
The fix applied when the test fails, not the test itself.
Key test
Use after a failure to cut inputs so the test then passes.
Example
Restrict x2 to x≥0

Formula & Notation

Worked Examples

Example 1 — Apply the test

Easy

Does f(x)=x3 pass the horizontal line test?
Show the steps and the answer
  1. Try a few heights: y=8 meets the graph only at x=2, y=−1 only at x=−1, and y=0 only at x=0.

    Each real number has exactly one real cube root, so each horizontal line hits the graph once.

  2. Check that the curve never turns around: if a<b then a3<b3.

    A function that always increases cannot come back to an earlier height, so no line can cross it twice.

  3. Conclude: x3 passes, and its inverse is x3.

    Every output comes from a single input, which the cube root returns, negatives included: −83=−2.

Answer: Yes — it passes, so f(x)=x3 is one-to-one and invertible

Takeaway: A function that always increases, or always decreases, passes the horizontal line test and has an inverse on its whole domain.

Example 2 — Looks like the same test but checks a different thing

Standard

Does the graph of a circle x2+y2=9 pass the VERTICAL line test?
Show the steps and the answer
  1. Draw the vertical line x=0: it meets the circle at (0,3) and (0,−3).

    One input, x=0, has two outputs, which a function cannot have.

  2. Note that every vertical line strictly between x=−3 and x=3 meets it twice.

    Solving for y gives y=±9−x2, two values for each such x.

  3. Keep the two tests apart: vertical lines ask whether a graph is a function, horizontal lines ask whether it is one-to-one.

    The circle fails both, but this question asked only about being a function.

  4. See a fix: the top half, y=9−x2, passes the vertical test.

    Splitting a curve into pieces can produce functions, much as restricting a domain can produce inverses.

Answer: No — it fails the vertical line test, so a circle is not a function

Takeaway: Vertical lines decide whether a graph is a function; horizontal lines decide whether a function is one-to-one.

Example 3 — Find the mistake: at most once, not exactly once

Application

Does f(x)=ex pass the horizontal line test? Kim writes: "No: the line y=−1 never meets the graph, so not every horizontal line crosses it once." Find the mistake and correct it.
Show the steps and the answer
  1. Restate the test: every horizontal line meets the graph at most once.

    Zero meetings are allowed; only two or more break one-to-one.

  2. Lines with y≤0 miss the graph, because ex>0 for every x.

    Heights the graph never reaches cannot give any output two inputs.

  3. Lines with y>0 meet it exactly once, at x=ln⁡y; for example y=5 at x=ln⁡5≈1.61.

    ex always increases, so it reaches each positive height exactly once.

  4. Conclude: ex passes, and its inverse ln⁡x is defined only for x>0.

    The heights the graph never reaches are exactly the inputs the inverse cannot accept.

Answer: Yes, ex passes; it is one-to-one, with inverse ln⁡x for x>0

Takeaway: A horizontal line that misses the graph is fine; the test fails only when some line hits it twice.

Where You'll See It

  • One voltage must mean one temperature

    A sensor's voltage must be one-to-one in temperature for the reading to mean anything. If its curve rose and then fell, a reading of 2.0 V might mean 10°C or 40°C. Engineers pick sensors, or operating ranges, where the graph passes the horizontal line test.

  • Why shipping costs cannot be undone

    A carrier charging $8 for any parcel from 1 kg up to 2 kg has a step-shaped cost graph. A horizontal line at $8 meets the whole step, so knowing the cost does not tell you the weight: the cost function has no inverse.

  • Letter-shift codes

    A code that maps letter number n (0 to 25) to 3n mod 26 is one-to-one, so every message can be decoded. The rule 2n mod 26 is not: it sends A (n=0) and N (n=13) to the same letter, so a receiver could not tell them apart.

Common Mistakes

  1. The slip: Using vertical lines instead of horizontal

    Instead: vertical lines test 'is it a function,' horizontal lines test 'is it one-to-one.'

  2. The slip: Declaring a function has no inverse forever

    Instead: it fails on its full domain but can pass after a domain restriction.

  3. The slip: Misreading 'at most once' as 'exactly once'

    Instead: a horizontal line may miss the graph entirely; what matters is that it never hits twice.


Mini Practice

Try these on your own. Tap Reveal when you want to check.

  1. Does f(x)=2x+5 pass the horizontal line test?

    Hint: Can two different inputs give the same output?

  2. Does f(x)=x2−6x pass the horizontal line test? If not, give two inputs with the same output.

    Hint: The parabola is symmetric about its vertex at x=3.

  3. The line y=4 is drawn on the graph of f(x)=x4. How many times does it meet the graph, and what does that tell you?

    Hint: Solve x4=4.

  4. Does f(x)=ex pass the horizontal line test? What happens with the line y=−1?

    Hint: Is missing the graph completely a failure?

  5. You want to know whether the curve x=y2 is a function of x. Horizontal or vertical line test?

    Hint: Which test checks for one output per input?

  6. A student writes: "f(x)=x2 fails the horizontal line test, so it can never have an inverse." Correct the mistake.

    Hint: What happens if you keep only half of the parabola?

Want the full set?

50 practice questions for this concept — free to try, every one with a complete worked solution showing the why, not just the answer.

Frequently Asked Questions

Can a graph pass the test in a calculator window and still fail?

Yes, because the window shows only part of the graph. y=x3−12xy=x^3-12x looks as if it only rises when the window runs from x=10x=10 to x=20x=20, but it turns around at x=±2x=\pm 2, so the line y=0y=0 crosses it three times, at x=0x=0 and x=±23x=\pm 2\sqrt{3}. When you know the formula, find the turning points or use algebra before trusting the picture.

What does the test have to do with reflecting a graph across y=x?

The inverse's graph is the reflection of the original across the line y=xy=x, and that reflection turns horizontal lines into vertical ones. So if some horizontal line meets the original twice, some vertical line meets the reflection twice, and the reflected curve is not a function. Passing the horizontal line test is exactly what makes the mirror image a graph of a function.

Do periodic functions such as sin⁡x always fail?

On their full domains, yes. A graph that repeats reaches each of its heights infinitely often, so sin⁡x=12\sin x=\frac{1}{2} at π6\frac{\pi}{6}, 5π6\frac{5\pi}{6}, 13π6\frac{13\pi}{6} and so on forever. That is why tan⁡−1\tan^{-1} and the other inverse trig functions are built from a single rising or falling stretch of the graph, such as −π2<x<π2-\frac{\pi}{2}<x<\frac{\pi}{2} for tangent.

Can a function with a gap or a jump still pass?

Yes. Breaks in the graph do not matter; only repeated heights do. f(x)=1xf(x)=\frac{1}{x} has a gap at 0 yet passes, since each height other than 0 is reached exactly once. A step function fails badly, though: the floor function ⌊x⌋\lfloor x\rfloor outputs 2 for every xx from 2 up to 3, so the line y=2y=2 runs along a whole piece of the graph.

Learning Path

Horizontal Line Test

You are here

Next →

Nothing after this yet
You need Inverse Function (what it means to undo a function), One-to-One Mapping (each output from just one input), and Function Notation. The horizontal line test turns that property into a quick visual check on a graph. From here you can choose restricted domains for x2, sin⁡x and cos⁡x, build the inverse trigonometric functions, and reflect a graph across y=x to sketch its inverse, knowing the result will be a function.

See Also