Finding if a function is onto? 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?
 A: The first piece is always positive since we always subtract something smaller than two from two.  The second piece is always positive because the reciprocal of a positive number is positive.  Thus, the value of the function is always positive.  Consequently, the function never takes the value zero nor any negative value.  Therefore, the function is not surjective.
The absolutely shortest way to see this is:
The first piece of the function would be zero at $x=2$, but two is not in the domain for that piece.  The second piece of the function is never zero.  Therefore the function never takes the value zero and thus cannot be surjective.
A: Let $y \in \mathbb{R}$, then $f$ is onto if there is $x \in \mathbb{R}$ such that 
$$ ( x \leq 1 \text{ and } 2-x=y )\quad \text{ or }\quad ( x>1\text{ and }  \frac{1}{x}=y)$$
Now note that
$$x \leq 1 \Rightarrow 2-x \geq 1 \quad \text{ and } \quad x>1 \Rightarrow 0<\frac{1}{x}<1,$$
It follows that $f$ is onto on $(0,\infty)$ but not on $\mathbb{R}$
A: Function $f:\mathbb{R}\rightarrow\mathbb{R}$ only takes positive
values, so it cannot be surjective.
