Is the following function onto? It is a piece-wise function.
Let the function $f:\mathbb{R}\rightarrow \mathbb{R}$ be $f(x)= \begin{cases} 2-x &, x\le 1 \\ \frac{1}{x} &, x>1 \end{cases}$
If we say $g(x)=2-x$ then it is one to one because make let $b\in \mathbb{R}$ then let $a=2-b$ $$f(a)=f(2-b)=2-(2-b)=b \qquad .$$
Thus it onto.
However $\frac{1}{x}$ let $b\in \mathbb{R}$ then it is not one to one b/c the codomain is all real but the range does not include zero.
Thus the function is not onto?