# Proving a function is onto and one to one

I'm reading up on how to prove if a function (represented by a formula) is one-to-one or onto, and I'm having some trouble understanding.

To prove if a function is one-to-one, it says that I have to show that for elements $a$ and $b$ in set $A$, if $f(a) = f(b)$, then $a = b$. I understand this to mean that if two elements in a domain map to the the same element in a codomain, then for the function to be one-to-one, they must be the same element because by definition, a one-to-one function has at most one element in the domain mapped to a particular element in the co-domain. Did I understand this correctly?

Then to prove that the function is onto, I'm reading an example that says "let's prove that $f: \mathbb{R} \rightarrow \mathbb{R}$ defined by $f(x) = 5x+2$ is onto, where $\mathbb{R}$ denotes the real numbers. We let $y$ be a typical element of the codomain and set up the equation $y =f(x)$. then, $y = 5x+2$ and solving for $x$ we get $x ={y-2\over 5}$. Since $y$ is a real number, then ${y-2\over 5}$ is a real number and $f({y-2\over 5})=5({y-2\over 5})+2=y.$

I'm not really seeing how that proves anything, so can anybody explain this to me?

• Onto means that the range of the function is the entire co-domain. In this case, the graph of $f(x) = 5x+2$ takes all possible $Y-$values. – Prahlad Vaidyanathan Oct 28 '13 at 17:19
• That means that $\exists x$ (namely, $\frac{y - 2}{5}$) such that $f(x) = y$. That is what onto means! – Don Larynx Dec 10 '13 at 0:56

Yes, your understanding of a one-to-one function is correct.

A function is onto if and only if for every $y$ in the codomain, there is an $x$ in the domain such that $f(x) = y$.

So in the example you give, $f:\mathbb R \to \mathbb R,\quad f(x) = 5x+2$, the domain and codomain are the same set: $\mathbb R.\;$ Since, for every real number $y\in \mathbb R,\,$ there is an $\,x\in \mathbb R\,$ such that $f(x) = y$, the function is onto. The example you include shows an explicit way to determine which $x$ maps to a particular $y$, by solving for $x$ in terms of $y.$ That way, we can pick any $y$, solve for $f'(y) = x$, and know the value of $x$ which the original function maps to that $y$.

Side note:

Note that $f'(y) = f^{-1}(x)$ when we swap variables. We are guaranteed that every function $f$ that is onto and one-to-one has an inverse $f^{-1}$, a function such that $f(f^{-1}(x)) = f^{-1}(f(x)) = x$.

• but..what I'm seeing is that if x is (y-2)/5, then f(x) = y. I don't see how that says that for EVERY x, f(x) = y, which I assume is what I'm trying to prove? – FrostyStraw Oct 28 '13 at 17:39
• $x = \frac{y-2}{5}$. Let's just pick any $y$: take $y = 2$. Then $x = \dfrac{2-2}{5} = 0$, so we see that there is an element in the domain, namely $x = 0$, that f maps to y = 2: $f(0) = 2$. What we've shown is simply that for any y whatsoever in the codomain, there exists an x in the domain such that $f(x) = y$. – Namaste Oct 28 '13 at 17:42
• although I guess it means that no matter what that x value represents numerically, it will give y if plugged in...hmm – FrostyStraw Oct 28 '13 at 17:43
• @amWhy: Nice write - up +1 – Amzoti Oct 29 '13 at 1:55
• when trying to prove that a fincion is onto, would it be formal argument to say: $f$ is onto because for every $x \in \text{image} f, \ x$ is necessarily $\in \text {dom} f$? – Jneven Aug 15 '18 at 10:48

A function $f:A\rightarrow B$ is one-to-one if whenever $f(x)=f(y)$, where $x,y \in A$, then $x=y$. So, assume that $f(x)=f(y)$ where $x,y \in A$, and from this assumption deduce that $x=y$.

A function $f: A\rightarrow B$ is onto if every element of the codomain $B$ is the image of some element of $A$. Let $y\in B$. We can show that there exists $x\in A$ such that $f(x)=y$. Choose $x=f^{-1}(y)$ and so $f(f^{-1}(y))=y$. So for all $y\in B$, there exists an $x\in A$ such that $f(x)=y$.

You can imagine that a function of X to Y is injective when you can "enter" a copy of X to Y.

$f\colon X\to Y$ is injective if and only if:

• $x\neq y\Rightarrow f(x)\neq f(y)$, or
• If $f(x)=f(y)\Rightarrow x=y$

Intuition says that you can have a replica of $X$ in $Y$, it means for all $x\in X$ there are a $y\in Y$ which $f(x)=y$ and there are not other $x'$ with the same statement, $\therefore$ Y contains a copy of the set X

Note

• It works for $X\to Y$, if we want something similar from $Y\to X$ it is called surjective.
• Is possible that for some $y\in Y, \not{\exists}x\in X$ such $f(x)=y$

## protected by Community♦Oct 22 '15 at 3:34

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?