# 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?

-
When you define your $a$, do you check if it is in $\{ x \le 1 \}$? Note that $x \mapsto 2-x$ is onto when viewed as a map $\mathbb{R}\to\mathbb{R}$, but it is not onto as a map $\left( -\infty,1 \right] \to \mathbb{R}$. – Jeppe Stig Nielsen Jul 12 '14 at 20:53

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.

-
yes that seem to make sense b/c the range is from 0 to infinity – Fernando Martinez Jul 12 '14 at 18:22
well from (0,infinity) – Fernando Martinez Jul 12 '14 at 18:35

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}$

-

Function $f:\mathbb{R}\rightarrow\mathbb{R}$ only takes positive values, so it cannot be surjective.

-