We know that functions are useful in algebra and calculus, but there are many different distinctions we can make. One of these is the idea of an onto function (also called a surjection).

So, when is a function onto? **A function f:A→B is onto if f(A) = B (the image of f is equal to the codomain of f). Each possible output y (in the set B) has an input x (in the set A) so that f(x) = y. In other words, we can always find an input value from the set A so that f can “reach” a particular output value in the set B.**

Of course, we will need to examine a function, its domain, its image, and its codomain to determine whether it is onto or not.

In this article, we’ll talk about when a function is onto and how to prove it. We’ll also look at some examples of onto functions (and also functions that are not onto).

Let’s get going.

## When Is A Function Onto?

A function f:A→B is onto if f(A) = B. This notation means that the image of f is equal to the codomain of f).

Intuitively, this means that for any element in the set B, we can find a corresponding element in the set A. So, for each value of y in B, we can find a value of x in A so that f(x) = y.

The domain and codomain make a big difference when we are trying to determine if a function is onto or not.

### Example 1: f(x) = 2x Is Onto for f:**R**→**R**

The function f(x) = 2x is onto when we consider its domain (all real numbers) and codomain (all real numbers).

This is easy to see: for any real number y, we simply divide by 2 to get x: x = y/2. This value of x will map to the desired value of y.

So, if we want to map to y = 2, we choose x = 1: f(1) = 2(1) = 2.

If we want to map to y = 7, we choose x = 3.5: f(3.5) = 2(3.5) = 7.

If we want to map to y = 12, we choose x = 6: f(6) = 2(6) = 12.

### Example 1: f(x) = 2x Is Not Onto for f:**Z**→**Z**

The function f(x) = 2x is not onto when we consider its domain (all integers) and codomain (all integers).

Remember that an integer has no fraction or decimal part: …,-3, -2, -1, 0, 1, 2, 3, …

So, the trick we used in the last example will not work:

If we want to map to y = 7, there is no way to do it. When we divide 7 by 2, we get 3.5, which is not an integer.

So, there is no number x in the set of integers that will map to y = 7 for the function f(x) = 2x.

Thus, there are numbers in the codomain (integers) that we cannot “reach” with the function f(x) = 2x and its domain (integers). Specifically, we cannot map to (reach) any odd numbers in the codomain.

## How To Prove A Function Is Onto Or Not

To prove a function f:A→B is onto, we must prove that each output y in the set B has an input in the set A so that f(x) = y.

### Example 1: Prove f(x) = x + 1 is onto for f:[0,1]→[1, 2]

First, consider an element y in the codomain of f: so, y is in the set [1, 2].

So, we need to find an element x in the domain of f so that f(x) = y.

Using the definition of the function f(x), we get:

**f(x) = y**[need an element x that maps to y]**x + 1 = y**[definition of the function f(x)]**x = y – 1**[solved for x]

So, given an element y, all we need to do is subtract 1 to find the value of x that maps to y.

Since y is in the set [1, 2], we can write the following inequalities:

**1 <= y <= 2**[since y is in the set [1, 2]]**1 – 1 <= y – 1 <= 2 – 1**[subtract 1 from all three parts of this inequality chain]**0 <= y – 1 <= 1**[simplify]**0 <= x <= 1**[since x = y – 1, which is what we solved for earlier]

This means that x is between 0 and 1, so x is in the set [0, 1], which is the domain of the function f.

Thus, f is onto for this domain and codomain.

### Example 2: Prove f(x) = x^{2} is not onto for f:**R**→**R**

To prove a function is not onto, all we need to do is find one element y in the set B (the codomain of f) that does not have an element x in A (the domain of f) with f(x) = y.

In this example, we can graph the function to see that it is never negative.

[insert graph of f(x) = x^{2}]

Since xis real, then x^{2} >= 0. Thus, the function f(x) = x^{2} always has an output greater than or equal to 0.

So, f(x) cannot map to any negative value y in the codomain (the real numbers).

We can easily see this by solving a value of x that maps to y = -1:

**f(x) = y**[need an element x that maps to y]**x**[definition of the function f(x)]^{2}= y**x**[we want to find an x that maps to y = -1]^{2}= -1**x = i**[take the square root of both sides of the equation]

This implies x = i (the square root of -1) is a solution. However, i is an imaginary number – it is not contained in the domain of f (the set of real numbers).

Thus, there is no value x in the domain of f that maps to y = -1. Thus, f(x) is not onto for this domain (real numbers) and codomain (real numbers).

## Can A Constant Function Be Onto?

A constant function can be onto if the codomain contains only the value of the constant function. Note that this will be a codomain with only one element.

### Example: A Constant Function That Is Onto

Consider the function f(x) = 1 for f:**R**→{1}

In this case, the function is onto, since the image of f is equal to the codomain of f:

**The image of f is the single value {1}, since any value of x in the domain (real numbers) maps to y = 1.****The codomain of f is given as {1}.**

## Is A Linear Function Onto?

A linear function can be onto in certain cases. It will depend on the given codomain of the function.

### Example 1: A Linear Function That Is Onto

Consider the linear function f(x) = 3x + 1 for f:**R**→**R**.

In this case, f(x) is onto. To prove this, consider any element y in the domain (real numbers).

Using the definition of the function f(x), we get:

**f(x) = y**[need an element x that maps to y]**3x + 1 = y**[definition of the function f(x)]**3x = y – 1****x = (y – 1) / 3**[solved for x]

So, given an element y, all we need to do is subtract 1 and divide the result by 3 to find the value of x that maps to y.

Since y is a real number, then y – 1 is real, and so (y – 1) / 3 is also real. So, x = (y – 1) / 3 is a real number, so there is a value of x that the function f will map to the value of y.

Thus, f(x) is onto.

### Example 2: A Linear Function That Is Not Onto

Consider the linear function f(x) = 2 for f:**R**→**R**.

In this case, f(x) is not onto. To prove this, all we need to do is find an output that f cannot map to.

Let’s choose y = 3, which is in the codomain (real numbers). The function f(x) = 2 can only map to 2, so it can never have an output of 3.

Thus, f(x) = 2 is not onto for this domain (real numbers) and codomain (real numbers).

## Is A Quadratic Function Onto?

A quadratic function can be onto in certain cases. It will depend on the given codomain of the function.

### Example 1: A Quadratic Function That Is Onto

Consider the quadratic function f(x) = x^{2} + 1 for f:[1, 2]→[2, 5]

In this case, f(x) is onto. To prove this, consider any element y in the domain [2, 5].

Using the definition of the function f(x), we get:

**f(x) = y**[need an element x that maps to y]**x**[definition of the function f(x)]^{2}+ 1 = y**x**^{2}= y – 1**x = √(y – 1)**[solved for x and took positive or principal square root]

** **So, given an element y, all we need to do is subtract 1 and take the square root of the result to find the value of x that maps to y.

Since y is in the set [2, 5], then we can write the following inequalities:

**2 <= y <= 5**[since y is in the set [2, 5]]**2 – 1 <= y – 1 <= 5 – 1**[subtract 1 from each part of the inequality chain]**1 <= y – 1 <= 4****√1 <= √(y – 1) <= √4**[take the principal square root of each part of the inequality chain]**1 <= √(y – 1) <= 2****1<= x <= 2**[since x = √(y – 1)]

So, the value of x that we solve for is in the domain [1, 2]. Thus, f(x) is onto.

### Example 2: A Quadratic Function That Is Not Onto

Consider the quadratic function f(x) = x^{2} for f:**R**→**R**. In this case, the function is not onto.

We can see this by considering the value y = -1 in the codomain (real numbers)

There is no value of x in the domain (real numbers) that will map to y = -1.

The value x = i will work, but i is an imaginary number, not a real number, so it is not in the domain of f.

Thus, f(x) is not onto in this case.

## Can A Function Be Onto & Not One To One?

A function can be onto and not one-to-one. Remember that a one-to-one function has only one x value that maps to a given y value.

### Example: A Function That Is Onto & Not One-To-One

Consider the function f(x) = x^{2} for f:**[-1, 1]**→**[0,1]**. This function is onto, but not one-to-one.

The function is onto because for any y value in the codomain [0, 1], we can simply take the square root to find a value of x that will map to y. Since the square root of a number in [0, 1] will also be in [0, 1], we know that x is in the domain of f, which is [-1, 1].

However, f is not one-to-one, since there are two input values that map to the same output. For example, consider x = 1 and x = -1:

**f(1) = 1**^{2}= 1**f(-1) = (-1)**^{2}= 1

Both inputs x = 1 and x = -1 map to the same output y = 1. So, f is not a one-to-one function.

## When Is A Function Not Onto?

A function f:A→B is not onto when there is at least one element y in the set B which has no element x in A that maps to y.

Of course, a function that is not onto can have more than one element in the codomain that cannot be mapped to from the domain.

## Conclusion

Now you know when a function is onto and when it is not. You also know how to prove a function is onto or how to prove it is not with a counterexample.

I hope you found this article helpful. If so, please share it with someone who can use the information.

Don’t forget to subscribe to my YouTube channel & get updates on new math videos!

~Jonathon