In math, one can use the horizontal line test to determine whether a function is one-to-one or injective. The picture below shows what a horizontal line test should look like.

The green line is the line we will use to run the test. It’s basically a horizontal line that can cross or intersect a graph in at least one point.

In the picture above, the line intersects the graph in two points and these points are (-1, -1) and (2, -1).

## Horizontal line test and one-to-one function

If a horizontal line test cuts the graph in more than one point, the graph is not one to one. Therefore, the above diagram is not one to one as the line intersects the diagram in two points.

See below another test for horizontal lines that only cuts the graph at one point.

Here we draw two lines to emphasize the fact that no matter how many horizontal lines you draw, this graphic will only ever be cut or intersected in one point.

Since in every horizontal line test the graph is only intersected at one point, we say that the graph immediately above it is one to one.

## What is the difference between a horizontal and a vertical line test?

The first diagram we drew above is not one to one because the horizontal line crossed the two points (-1, -1) and (2, -1). As you can see here, two different x-values - 1 and 2 – are mapped to the same y-value or -1

When doing a horizontal line test, each x-value in the domain should be mapped to a different y-value in the range each time.

Conversely, if you are doing a vertical line test, each y-value in the range should be mapped to a different x-value in the domain.