can you make a function that equals $y=x$ at only if $x$ is a rational number

50 Views Asked by At

The title says it all, I am looking for a function that equals $y=x$ for every $x \in \mathbb{Q}$but that does not equals $y=x$ when the value of $x \notin \mathbb{Q}$.

The function does not necessarily have to be continuous.

It does not matter how the function behaves in the complex plane.

3

There are 3 best solutions below

0
On BEST ANSWER

Define

$$f(x) = \begin{cases} x ~~~~~ \text{for}~~ x\in \mathbb{Q} \\ 0 ~~~~~ \text{for}~~ x \not\in \mathbb{Q} \end{cases} $$

2
On

Hint: Do you know the Dirichlet function (which is the indicator function of the rational numbers)? Maybe start with that and modify it to suit your needs.

0
On

Let $ f:\mathbb R \to \mathbb R $ by $ f(x) = x \cdot \chi_{\mathbb Q }(x) $ where $ \chi_{\mathbb Q} $ is the indicator function of the rationals in $ \mathbb R $. Then $ f(x) = x \iff x \in \mathbb Q $, as $ 0 \in \mathbb Q $.