One-one, onto and inverse functions · Mathematics Class 11–12 | StemPy Lab
Course 1.3·Lesson 2 of 3
One-one, onto and inverse functions
A function is one-one if different inputs always give different outputs, and onto if every element of the codomain is an output. A function that is both has an inverse f⁻¹, which undoes f. We find the inverse by swapping x and y and solving. The graphs of f and f⁻¹ are mirror images in the line y = x.
about 30 min1 simulation2 practice questions
Lesson 2 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
One-one functions
A function sends every input to one output. It may send two inputs to the same output. When it never does, we call it one-one (or injective):
f(a)=f(b)⟹a=b
In words: different inputs always give different outputs. The function f(x)=2x+3 is one-one. If 2a+3=2b+3, then a=b. The function f(x)=x2 is not one-one on R, because f(2)=f(−2)=4.
The horizontal line test. A function is one-one if and only if no horizontal line meets its graph more than once. A horizontal line is the line of one fixed output, and meeting the graph twice means that one output has two inputs.
Two graphs with a horizontal dashed line. On the left, the curve y equal to x cubed over 2 plus 1 rises all the way, and a horizontal line meets it once, so it is one-one. On the right, the parabola y equal to x squared is met by a horizontal line at two points, so it is not one-one.
Onto functions
The codomain is the set where the outputs are allowed to be. The range is the set of outputs that actually occur. A function is onto (or surjective) when the range is the whole codomain: every element of the codomain is hit.
f(x)=x2 from R to R is not onto, because no square is negative, so −1 is never reached. The same rule from R to [0,∞) is onto.
This shows that whether a function is onto depends on the codomain that we choose. A function is also one-one or not only on the domain that we choose. Compare x2 on R and x2 on [0,∞): on the second domain it is one-one.
The four cases
Four arrow diagrams between two sets. The first is one-one but not onto: 1 goes to a and 2 goes to b, and c has no arrow. The second is onto but not one-one: 1 and 2 both go to a, and 3 goes to b. The third is both one-one and onto: 1 goes to b, 2 to c and 3 to a. The fourth is neither: 1 and 2 go to a, 3 goes to b, and c is not used.
A function that is both one-one and onto is called a bijection. It pairs every element of the domain with exactly one element of the codomain, and no element of the codomain is left out.
Counting. Let A have m elements and B have n elements.
The number of functions from A to B is nm. Each of the m elements has n choices.
The number of one-one functions is n(n−1)(n−2)⋯(n−m+1), when n≥m. The first element has n choices, the next n−1, and so on. When n<m there are none.
For two finite sets with the same number of elements, one-one and onto go together: if a function is one of them, it is also the other.
The inverse function
If f sends a to b, can we go back from b to a? We can do it for every b only if two things hold. Every b must come from some a, so the function must be onto. And only one a may give that b, so the function must be one-one.
A function has an inverse if and only if it is a bijection. The inverse f−1 is the function that undoes f:
f−1(f(x))=xandf(f−1(y))=y
The notation f−1 does not mean f1. For f(x)=2x, f−1(x)=2x, and f(x)1=2x1 is a different thing.
How to find the inverse
Write y=f(x).
Solve for x in terms of y.
Swap the names, so that the input is again called x. The result is f−1(x).
Example 1.f(x)=3x−5. Then y=3x−5, so x=3y+5. The inverse is f−1(x)=3x+5.
Example 2.f(x)=x2 on [0,∞). This is a bijection onto [0,∞). Solving y=x2 gives x=y (we take the positive root, because the domain has x≥0). So f−1(x)=x.
Example 3.f(x)=x−32x+1. From y(x−3)=2x+1 we get x(y−2)=3y+1, so x=y−23y+1. The inverse is f−1(x)=x−23x+1. The domain of f is R−{3} and its range is R−{2}. For f−1 the two are swapped: its domain is R−{2} and its range is R−{3}.
The graph of the inverse
If (a,b) is on the graph of f, then (b,a) is on the graph of f−1. Swapping the coordinates is a mirror image in the line y=x. So the graph of f−1 is the mirror image of the graph of f in the line y=x.
The curve f of x equal to x squared for x at least 0, in blue, and its inverse, the square root of x, in orange, with a dashed grey line y equal to x between them. The point 2 and 4 on the blue curve and the point 4 and 2 on the orange curve are marked in red. The two curves are mirror images in the dashed line.
The point (2,4) is on f(x)=x2, and the point (4,2) is on f−1(x)=x.
The inverse of a composite. To undo "first f, then g", we must undo g first and then f:
(g∘f)−1=f−1∘g−1
You took your socks and your shoes on in this order. You take them off in the reverse order.
Follow the dashed segment from the blue dot to the red one: it always crosses y=x at a right angle. That is what a reflection in y=x means.
Practise with new numbers
Try it in Python
This program turns temperatures from celsius to fahrenheit and back with the inverse function. It tests that the inverse undoes the function.
Remember these
One-one: different inputs, different outputs. Test: no horizontal line meets the graph twice.
Onto: the range is the whole codomain.
An inverse exists only for a function that is both (a bijection).
To find f−1: write y=f(x), solve for x, and swap the names.
The graph of f−1 is the mirror image of the graph of f in the line y=x.
(g∘f)−1=f−1∘g−1.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Is f(x)=∣x∣ from R to R one-one? Is it onto?
Find the inverse of f(x)=3x+4.
How many one-one functions are there from a set of 2 elements to a set of 5 elements?
Why does f(x)=x2, from R to R, have no inverse?
Enroll free in Combining and Reversing Functions
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.