Functions

The Vertical Line Test: Is This Graph a Function?

A graph is the graph of a function exactly when no vertical line x=cx = c crosses it more than once. If a single vertical line hits the curve twice, one input has two outputs, so it is not a function.

x=c meets the graph at most once, for every cx = c \text{ meets the graph at most once, for every } c

The test is a picture of the definition, which makes it fast. It also has edge cases that cost points: dots at jumps, shapes that open sideways, and the mix-up with the horizontal line test. Each one is covered below with worked examples.

Why does the vertical line test work?

A function assigns each input exactly one output. Every function is a relation, but a relation such as a circle can pair one input with several outputs. That extra condition is what the test checks.

The vertical line x=cx = c is the set of every point whose input is cc, namely (c,y)(c, y) for all yy. Sweeping it across the plane collects all outputs of one input in a single stroke. Each place it meets the graph is an output of cc, so the number of crossings is the number of outputs. For a function that number never exceeds one, which is why function notation can write f(c)f(c) as one definite value.

function  ⟺  for every c, the line x=c meets the graph at most once\text{function} \iff \text{for every } c,\ \text{the line } x = c \text{ meets the graph at most once}

“At most” is deliberate. Zero crossings is fine: it only means cc is not in the domain. Lines are vertical because the input conventionally sits on the horizontal axis. If a problem asks whether xx is a function of yy, the roles swap and horizontal lines do the job.

Quick check

A graph contains the points (4,7)(4, 7) and (4,−1)(4, -1). Can it be the graph of a function of xx?

How do you use the vertical line test on a graph?

Hold a pencil upright at the far left of the graph and slide it right. At each position, count how many points of the curve it touches.

  1. Decide which variable is the input (usually xx).
  2. Sweep an upright line across the whole graph, left to right.
  3. Watch the places where the curve folds back, loops, or has a vertical edge. Failure can only happen there.
  4. If the line ever touches two or more points at once, stop. The graph fails.

Passing is a claim about every line, while failing needs only one. That asymmetry is the trap. Checking three or four lines and declaring victory is how a graph with a small loop at one end gets mislabeled. Scan for any spot where one part of the curve sits directly above another part.

Jumps in piecewise functions need a close look at the dots. A filled dot stacked above a filled dot at the same xx fails. A filled dot above an open dot passes, because an open dot is not on the graph. The same sweep also reads off the domain and range: the domain is every xx-position where the pencil touches something.

Try this: Sketch y=x2y = x^2 and sweep an upright pencil across it. Then turn the paper a quarter turn and sweep again. Explain why the verdict changed.

Which graphs fail the vertical line test?

Three families fail: closed curves (circles and ellipses), curves that open sideways (like x=y2x = y^2), and vertical lines. In each, some xx-values have graph points both above and below. To prove failure, pick one such xx and name both points.

Worked example 1. Decide whether x2+y2=25x^2 + y^2 = 25 is a function of xx. The circle spans xx from −5-5 to 55, so choose an inside value, x=3x = 3, and substitute:

32+y2=25  ⇒  y2=16  ⇒  y=4 or y=−43^2 + y^2 = 25 \;\Rightarrow\; y^2 = 16 \;\Rightarrow\; y = 4 \text{ or } y = -4

Check: 32+42=253^2 + 4^2 = 25 and 32+(−4)2=253^2 + (-4)^2 = 25. The line x=3x = 3 meets the circle at (3,4)(3, 4) and (3,−4)(3, -4), so the relation fails the test and is not a function.

One bad line is enough

To fail a graph, name a single input with two outputs, such as x=3x = 3 giving 44 and −4-4. To pass a graph, the argument must cover every xx at once.

The same failure repeats for every xx with −5<x<5-5 < x < 5. Only the leftmost and rightmost points, x=±5x = \pm 5, are met once. A vertical line that merely grazes the circle there does not rescue it, because the test demands every line. The sideways parabola x=y2x = y^2 behaves the same way: each x>0x > 0 gives y=±xy = \pm\sqrt{x}.

How do you apply the vertical line test to an equation?

No graph is needed. Solve the equation for yy and look at what comes out. One expression means a function. A ±\pm means two outputs for most inputs, so it fails. The fastest mental check is to plug in one convenient xx and count the yy-values. An even power of yy (y2y^2, y4y^4, ∣y∣|y|) is the usual warning sign, while an odd power such as y3y^3 is not.

Worked example 2. Test x=y2−4x = y^2 - 4. Solve for yy:

y2=x+4  ⇒  y=±x+4y^2 = x + 4 \;\Rightarrow\; y = \pm\sqrt{x + 4}

At x=0x = 0 this gives y=2y = 2 or y=−2y = -2. Check: 22−4=02^2 - 4 = 0 and (−2)2−4=0(-2)^2 - 4 = 0. One input, two outputs, so it is not a function.

Worked example 3. Test x=y3+1x = y^3 + 1. Solve for yy:

y3=x−1  ⇒  y=x−13y^3 = x - 1 \;\Rightarrow\; y = \sqrt[3]{x - 1}

Every real number has exactly one real cube root, so each xx gives one yy. Check with x=9x = 9: y=2y = 2, and 23+1=92^3 + 1 = 9. This graph lies on its side like a sideways cubic, yet it passes. Looking sideways is not the problem. Having two outputs is.

The absolute value graph y=∣x∣y = |x| is a V that passes. Swap the roles to get ∣y∣=x|y| = x, a V on its side, and at x=3x = 3 you get y=3y = 3 or y=−3y = -3, so it fails.

Quick check

Does xy=6xy = 6 pass the vertical line test?

Do holes, jumps and vertical lines break the vertical line test?

A vertical line x=4x = 4 fails dramatically: every point on it has input 44, so one input has infinitely many outputs. That is also why it has no slope-intercept form, since its slope is undefined. A horizontal line y=3y = 3 passes, because every input gives the same single output.

Holes cannot cause a failure. A hole deletes a point, so a vertical line through it meets the graph fewer times, never more. Students sometimes drop a line through a hole, see a gap, and think something is wrong. Nothing is: a gap only removes an input from the domain.

Jumps are the subtle case. Take f(x)=x+1f(x) = x + 1 for x≤2x \le 2 and f(x)=x−1f(x) = x - 1 for x>2x > 2. The graph jumps, but on the line x=2x = 2 only (2,3)(2, 3) is a real point, because (2,1)(2, 1) is an open dot. It passes. Change the second rule to x≥2x \ge 2 and both dots are filled, giving (2,3)(2, 3) and (2,1)(2, 1), so it fails.

One more trap involves the radical sign. The equation y=25−x2y = \sqrt{25 - x^2} passes, because  \sqrt{\ } means the nonnegative root only. It is the upper semicircle. The ±\pm only appears when it is added by hand.

Graph Passes? Reason
y=mx+by = mx + b Yes one output per input
x=4x = 4 No every yy is paired with 44
y=3y = 3 Yes same single output everywhere
y=x2y = x^2 Yes only the point (a,a2)(a, a^2) at x=ax = a
x=y2x = y^2 No y=±xy = \pm\sqrt{x} when x>0x > 0
y=25−x2y = \sqrt{25 - x^2} Yes upper semicircle only
x2+y2=25x^2 + y^2 = 25 No top and bottom halves

Vertical line test vs horizontal line test: the difference

The two tests answer different questions. The vertical test asks whether a graph is a function. The horizontal test asks whether a function is one-to-one, meaning no output is shared by two inputs. A horizontal line hitting a graph twice means two inputs share an output, which breaks one-to-one but not function-hood.

The parabola y=x2y = x^2 shows the split. It passes the vertical test. The horizontal line y=9y = 9 meets it at (3,9)(3, 9) and (−3,9)(-3, 9), so it fails the horizontal test. The pattern is general: every even function fails the horizontal test, because f(−a)=f(a)f(-a) = f(a) pairs each nonzero input with its opposite.

Swapping xx and yy swaps the tests

Reflecting a graph over the line y=xy = x turns vertical lines into horizontal ones. That is why an inverse is a function exactly when the original passes the horizontal test.

Restricting the domain repairs the problem. Keep only x≥0x \ge 0 and y=x2y = x^2 passes both tests, so its inverse y=xy = \sqrt{x} is a function. The details are in the lessons on the inverse of a quadratic function and the inverse of a square root function.

Transformations of functions preserve the vertical verdict when they shift, stretch, or reflect across either axis. A function stays a function. A quarter turn is not one of those moves, which is why your paper rotation in the pencil exercise changed the answer.

Quick check

The graph of f(x)=x2−4f(x) = x^2 - 4 passes the vertical line test. Does it pass the horizontal line test?

Where is the vertical line test used in real life?

Any quantity that depends on time must pass the test, because nothing can have two values at the same moment. A position-versus-time graph for a car on a straight road is a function: the car is in one place at each instant. If recorded data produces two different positions at the same timestamp, something is wrong with the sensor or the logging, not the car.

The same idea guards data tables. A lookup table, a spreadsheet column used as a key, or a dictionary in code behaves like a function only if each key has one value. Duplicate keys with different values are a vertical line test failure in disguise.

Graphing tools also depend on it. A calculator that plots y=…y = \ldots expressions cannot draw a circle in one entry. The circle x2+y2=25x^2 + y^2 = 25 is drawn as two functions, y=25−x2y = \sqrt{25 - x^2} and y=−25−x2y = -\sqrt{25 - x^2}, each of which passes the test. Splitting a failing relation into passing pieces is a standard move whenever a function is required.

Practice problems

0 of 5 solved

  1. Does the graph of y=2x−5y = 2x - 5 pass the vertical line test?

  2. Does x2+y2=16x^2 + y^2 = 16 pass the vertical line test?

  3. Is yy a function of xx when x=y2−9x = y^2 - 9?

  4. Does y=16−x2y = \sqrt{16 - x^2} pass the vertical line test?

  5. For what value of aa is f(x)=x+1f(x) = x + 1 for x≤2x \le 2, and f(x)=ax−1f(x) = ax - 1 for x≥2x \ge 2, a function?

Common questions

What is the vertical line test?

It is a visual check for whether a graph shows a function. If every vertical line crosses the graph at most once, each input has one output and the graph is a function. If any vertical line crosses it twice or more, it is not.

Does a circle pass the vertical line test?

No. For any xx strictly between the leftmost and rightmost points, the vertical line hits the top half and the bottom half. For x2+y2=25x^2 + y^2 = 25, the line x=3x = 3 meets the circle at (3,4)(3, 4) and (3,−4)(3, -4).

Can a graph pass the vertical line test and still fail the horizontal line test?

Yes. The parabola y=x2y = x^2 is a function, so it passes the vertical test, but y=9y = 9 hits it at x=3x = 3 and x=−3x = -3, so it fails the horizontal test. Such a function is not one-to-one.

What if a vertical line does not touch the graph at all?

That is fine. Zero crossings only means that input is outside the domain. The test fails only when a line crosses the graph two or more times.

Does the line x = 4 pass the vertical line test?

No. The line x=4x = 4 contains infinitely many points with input 44, so one input has infinitely many outputs. A horizontal line such as y=3y = 3 does pass.

How do you test whether x is a function of y?

Swap the roles of the axes and use horizontal lines. If every horizontal line meets the graph at most once, then xx is a function of yy. For x=y2x = y^2, the answer is yes, even though yy is not a function of xx.

Up next