# Injective and surjective function

Determine whether or not the following function is injective and/or surjective.

$$f:\mathbb R \to \mathbb R$$

$$f(x)= \begin{cases}2x &: \text{if }x \text{ is an integer}\\ x &: \text{otherwise}\end{cases}$$

I was able to prove that the function was injective for both cases, $f(x)=2x$ and $f(x)=x$. I am having a harder time determining if it is also surjective. I want to say that it is not surjective since $3\in\mathbb R$ there is no $x\in\mathbb Z$ such that $2x=3$. Is that enough to say that the function is not surjective?

• Yes, that is enough to show that $f$ is not surjective. Oct 20 '13 at 23:04
• Yep that's pretty much it. You of course need to show that $f$ is injective, not just the functions $x\mapsto 2x$ and $x\mapsto x$ Oct 20 '13 at 23:04

Is $f$ surjecitive ? Your answer is correct if $f(x)=3$ then $x=3$ and $x$ not integer or $2x=3$ and $x$ integer. That is not possible.
Is $f$ injective ? Hint: show that If for $x,y \in {\mathbb R}$, $f(x)=f(y)$ then $x$ and $y$ are both integers or both are not integers.