What is a one-to-one function?
Last updated: 2026-11-25
A one-to-one function is a function where each output comes from only one input: if f(a) = f(b), then a = b. Two different inputs do not land on the same output. You test a graph with the horizontal line test: if any horizontal line crosses the graph more than once, the function is not one-to-one.
Start learning No account needed
The definition follows the Wikipedia article on injective functions, which lists "one-to-one function" as another name for an injective function, and the horizontal line test article.
One-to-one matters because of inverses. The Wikipedia article on inverse functions says the inverse of a function exists if and only if the function is injective, that is, one-to-one, and it shows how restricting the domain can make a function one-to-one.
A worked example: x squared and x cubed
Take two functions on the real numbers, f(x) = x^2 and g(x) = x^3. Apply the horizontal line test to each one. The values below are computed by scripts/what-is-a-one-to-one-function-worked-example.py in the Professor Turing repository.
- f(x) = x^2. Draw the horizontal line y = 9. It crosses the graph at x = 3 and at x = -3, because f(3) = 9 and f(-3) = 9. One line crosses the graph twice, so f is not one-to-one. The same thing happens at y = 1, 4, 16 and 25, each with a pair of inputs that differ only in sign.
- g(x) = x^3. Draw the line y = 27. It crosses the graph once, at x = 3. Lines at other heights also cross once. On the whole numbers from -5 to 5 no output repeats.
- Why a grid is not the proof for g. Whole-number inputs can show that a function fails the test, because one repeated output is enough. They cannot show that a function passes, since a repeat could sit between the points you tried. For g the algebra does it: if a^3 = b^3, then (a - b)(a^2 + ab + b^2) = 0, and the second factor is zero only when a and b are both 0. So a = b, which is the definition.
The Wikipedia article on inverse functions uses the same square function. It says the inverse of a function exists only when the function is injective, and that restricting the domain of x² to the nonnegative reals makes it bijective and invertible, with the positive square root as its inverse. The script agrees: on x = 0 to 5 no output of x^2 repeats.
Output from the script:
f(x) = x^2 on x = -5..5, outputs reached more than once: {25: (-5, 5), 16: (-4, 4), 9: (-3, 3), 4: (-2, 2), 1: (-1, 1)}
g(x) = x^3 on x = -5..5, outputs reached more than once: {}
horizontal line y = 9: f(3) = 9, f(-3) = 9 -> two crossings; g: x with g(x) = 27 is 3
f(x) = x^2 restricted to x = 0..5, repeats: {}
double n -> 2n on -10..10, repeats: {} | is 1 an output? False
n mod 2 on 0..3, repeats: {0: (0, 2), 1: (1, 3)} | outputs: (0, 1)
h(x) = x^3 - 3x at x = -2, 0, 2: (-2, 0, 2) | repeats: {}
h(x) = x^3 - 3x on x = -2..2, repeats: {-2: (-2, 1), 2: (-1, 2)}
self-test: |2| = |-2| = 2; 2x+5 repeats on grid: {}; |x| on 0..5 repeats: {}
Two mistakes students make
1. Mixing up one-to-one and onto
One-to-one is about inputs: no two inputs share an output. Onto (the word for a surjective function) is about outputs: each value in the codomain gets hit at least once. A function can have one property without the other.
- One-to-one but not onto. Double a whole number: n goes to 2n. No output repeats, so it is one-to-one. The output 1 is not reached, because it would need n = 1/2, so it is not onto the whole numbers.
- Onto but not one-to-one. Send a whole number to the remainder when you divide by 2 (n mod 2), with outputs in {0, 1}. Both outputs are reached, so it is onto. But 0 and 2 both give 0, so it is not one-to-one. The Wikipedia article on surjective functions uses this same function as an example of an onto function.
Also watch the name "one-to-one correspondence". The injective function article warns that it is not the same as a one-to-one function: a one-to-one correspondence is a bijection, which is both one-to-one and onto. The horizontal line test article gives the graph version of each: a function is onto when any horizontal line crosses the graph at least once, and a bijection when any horizontal line crosses it exactly once.
2. Testing only a few points
Try three inputs, see three different outputs, and it is tempting to call the function one-to-one. Take h(x) = x^3 - 3x. At x = -2, 0 and 2 the outputs are -2, 0 and 2, all different. But the line y = -2 also crosses the graph at x = 1, since h(1) = -2, and the line y = 2 crosses it at x = -1. So h fails the test, and the three points you picked happened to miss the repeats.
A few points can show that a function is not one-to-one, but they cannot show that it is. To show it is, use the algebra (assume f(a) = f(b) and work out that a = b) or look at the whole graph.
Test yourself
Work each question on paper first. Open the answer after you have written yours.
Question 1. Is f(x) = 2x + 5 one-to-one? Say why.
Answer to question 1
Yes. Suppose f(a) = f(b). Then 2a + 5 = 2b + 5, so a = b. On the graph, a straight line with a nonzero slope is crossed once by any horizontal line.
Question 2. Is f(x) = |x| one-to-one? If not, give two inputs that share an output.
Answer to question 2
No. f(2) = 2 and f(-2) = 2, so the line y = 2 crosses the graph twice. If you restrict the domain to x ≥ 0, no output repeats and the restricted function is one-to-one.
Question 3. A friend says that f(x) = x^2 on x ≥ 0 is onto the real numbers because it is one-to-one. What is the mix-up?
Answer to question 3
One-to-one and onto are separate properties. On x ≥ 0, x^2 is one-to-one, but its outputs are all 0 or larger, so a negative number such as -4 is not reached. It is not onto the real numbers. It is onto the numbers from 0 up, the set of outputs it does reach.
Explain it back
After you finish the questions, close the page and explain a one-to-one function out loud or on paper to someone who has not taken the course, using one function of your own. Say what the horizontal line test looks for, and why a repeated output means two inputs are sharing it. Where you stop or reach for a word you cannot define, that is the step to study next. A research review by Dunlosky and colleagues, who looked at ten study techniques, rated self-explanation as moderate in usefulness and said the evidence for it in classrooms is limited. So treat explaining it back as a reasonable thing to try, not as a proven method. Source: Dunlosky et al., 2013, Psychological Science in the Public Interest, abstract read on 2026-11-23.
How Professor Turing helps
Professor Turing is a tutor for adults learning any subject, in college or on their own. It asks you questions instead of giving the final answer, does not grade a bare guess, and remembers what you got wrong. No account is needed to start. It's an AI tutor, free to try.
Bring the function you are stuck on. Its first reply asks about your attempt, such as what you tried with the inputs and outputs, before it teaches anything, and if you send an answer with no steps it asks how you got there. You must be 18 or older. Guest conversations are deleted 7 days after your last activity; with an account they are kept while the account is active.
FAQ
What does one-to-one mean for a function? Each output comes from one input only. If two inputs give the same output, those inputs must be the same number.
Is a one-to-one function the same as an onto function? No. One-to-one is about inputs sharing an output. Onto is about each output value being reached. A function that is both is a bijection.
Why do I need a function to be one-to-one? To have an inverse function. The Wikipedia article on inverse functions says the inverse exists if and only if the function is one-to-one, and that restricting the domain can make a function one-to-one.
Start with what you're working on
Tell the tutor which function you are stuck on and let it ask you the questions.
Start learning No account needed
See also: all study guides