Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|cite|improve this question
@drhab: Answers are not comments. Answers should be posted in the large box headed by "Your Answer". – Eric Towers Jul 12 '14 at 18:20
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
up vote 5 down vote accepted

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.

share|cite|improve this answer
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}$

share|cite|improve this answer

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

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.