How to Determine If a Graph Is a Function: Vertical Line Test

A graph represents a function if every x-value on the graph corresponds to exactly one y-value. The quickest way to check this visually is the vertical line test: imagine sweeping a vertical line across the graph from left to right. If that line ever crosses the graph at more than one point simultaneously, the graph is not a function.

Why a Function Allows Only One Output

A function is a rule that assigns each input exactly one output. If you plug in an x-value and get back two different y-values, the rule is broken. Think of it like a vending machine: you press one button, you expect one item. A machine that randomly dispenses two different snacks for the same button isn’t functioning properly, and neither is a mathematical relation that gives two outputs for one input.

This shows up clearly when you look at ordered pairs. The set {(1, 5), (3, 3), (2, 3), (4, 2)} is a function because no x-value repeats with a different y-value. Notice that two different inputs (3 and 2) share the same output of 3, and that’s perfectly fine. The rule only cares about inputs, not outputs. But the set {(1, 5), (4, 2), (2, 3), (3, 3), (1, 6)} is not a function because x = 1 maps to both 5 and 6.

How the Vertical Line Test Works

The vertical line test translates that same logic onto a graph. A vertical line represents every point that shares a single x-value. If the graph crosses that vertical line in two or more places, then that one x-value has produced multiple y-values, which violates the definition of a function.

To apply it, picture sliding a vertical line (like the edge of a ruler) across the entire graph from the far left to the far right. At every position along the x-axis, check whether the line touches the graph more than once. If it never does, the graph passes the test and represents a function. If it touches twice or more at any position, even just one, the graph fails.

You don’t need to check every possible vertical line mentally. Focus on the parts of the graph where curves bend back on themselves, where two branches exist above and below each other, or where the shape is widest. These are the spots most likely to fail.

Common Graphs That Are Not Functions

Several familiar shapes fail the vertical line test every time:

  • Circles. A circle like x² + y² = 9 has two y-values for most x-values, one on the top half and one on the bottom. A vertical line through the center crosses the circle twice.
  • Ellipses. Same problem as circles, just stretched. Any vertical line between the leftmost and rightmost points hits the graph in two places.
  • Sideways parabolas. A parabola that opens left or right (like x = y²) fails because a single x-value lands on both the upper and lower branches.
  • Vertical lines. A vertical line itself, such as x = 3, is not a function. It has one x-value paired with infinitely many y-values.

Equations written as y = ±something are a giveaway. The “±” means each x-value produces two y-values, one positive and one negative. For instance, y = ±√x gives both 2 and -2 when x = 4.

Graphs That Pass Despite Looking Tricky

Some graphs look complicated but are still functions. A horizontal line like y = 5 passes the vertical line test easily: every vertical line hits it at most once. Parabolas that open up or down (y = x²) pass too, because each x-value only touches one point on the curve. Even wildly oscillating graphs like sine waves pass, as long as each vertical slice hits the graph just once.

Piecewise functions, those graphs built from separate pieces on different intervals, can also pass the test. The key is what happens at the boundaries where one piece ends and the next begins. You’ll often see open and closed circles at these transition points. A closed (filled-in) circle means the point is included in the graph. An open (hollow) circle means it’s not. If two pieces meet at the same x-value, the graph is still a function as long as only one of the two endpoints is a closed circle. Two closed circles stacked at the same x-value would mean that x-value has two real outputs, and the graph would fail.

Checking a Table or Set of Points

If you’re working with a table of values or a scatter plot instead of a continuous curve, the principle is identical. Scan the x-column (or the x-coordinates) for any repeats. If the same x-value appears twice with different y-values, it’s not a function. If every x-value is unique, or if repeated x-values always pair with the same y-value, you have a function.

For a scatter plot, this is just the vertical line test applied to dots instead of a curve. If any two dots sit directly above or below each other (sharing the same x-coordinate), the relation is not a function.

Vertical Line Test vs. Horizontal Line Test

You may see a related concept called the horizontal line test, and it’s worth knowing the difference. The vertical line test tells you whether a graph is a function at all. The horizontal line test tells you whether a function is one-to-one, meaning each y-value also maps back to only one x-value. A function passes the horizontal line test when no horizontal line crosses the graph more than once.

These are separate questions. The graph of y = x² passes the vertical line test (it is a function) but fails the horizontal line test (both x = 3 and x = -3 produce y = 9, so it’s not one-to-one). The horizontal line test only matters when you need to determine whether a function has a valid inverse. For the basic question of “is this a function,” stick with the vertical line test.