Functions can be considered math machines. When you give them input, they give you an output. There are three basic types of functions in math that are commonly used and studied – one-to-one, onto, and many-to-one functions. The horizontal line test is an easy way to check whether a function is a one-to-one function or not.

## What is a One-To-One Function?

A one-to-one function is defined by $f: A → B$ such that every element of set $A$ is connected to a distinct element in set $B$. The one-to-one function is also called an **injective function**. Here every element of the domain has a distinct image or co-domain element for the given function.

Consider the following functions:

- The identity function $f:R → R$, $f(x) = x$ is injective.
- Function $f: R→ R$, then $f(x) = 3x$ is injective.
- Function $f: R→ R$, then $f(x) = 3x – 2$ is injective.
- Function $f: R→ R$, then $f(x) = x^2$ is not an injective function, because here if $x = -1$, then $f(-1) = 1 = f(1)$. Since, for two values in the domain, there exists only one value in the co-domain.
- Function $f: R→ R$, then $f(x) = \frac {x}{2}$ is injective.
- Function $f: R→ R$, then $f(x) = x^3$ is injective.

## Horizontal Line Test

The horizontal line test is a simple, visual way to tell whether a function is one-to-one or not. The horizontal line in a coordinate system represents a set of infinite points having the same $y$ coordinate values and different $x$ coordinate values for each of its points. The horizontal line is drawn parallel to the $x$-axis if it cuts the curve at one distinct point then every value of $x$ in a function is mapped with one and only one value of $y$ and hence, the function will be one-to-one. If the horizontal line cuts the graph at more than one point, then it means the function is not one-to-one or injective function.

Let’s perform the horizontal line test with the above functions.

$f(x) = x$

The horizontal line crosses the graph at only one point, therefore, $f(x) = x$ is a one-to-one function.

$f(x) = 3x$

The horizontal line crosses the graph at only one point, therefore, $f(x) = 3x$ is a one-to-one function.

$f(x) = 3x – 2$

The horizontal line crosses the graph at only one point, therefore, $f(x) = 3x – 2$ is a one-to-one function.

$f(x) = x^2$

The horizontal line crosses the graph at two points (more than one point), therefore, $f(x) = x^2$ is **NOT** a one-to-one function.

$f(x) = x^3$

The horizontal line crosses the graph at only one point, therefore, $f(x) = x^3$ is a one-to-one function.

## Conclusion

There are many concepts like the inverse of a function that requires a function to be one-to-one. The horizontal line test is the easiest and quickest way of checking whether a given function is one-to-one or not.

## Recommended Reading

Image Credit: Trigonometry vector created by macrovector_official – www.freepik.com