Is there a simple function $f(x)$ that follows $2$ rules when $x$ is rational?

101 Views Asked by At

Is there a simple function $f(x)$ that follows $2$ rules when $x$ is rational?

$x$'s simplest form is $\frac{a}{b}$ if $x$ is a rational number.

$$f(x) \in \begin{cases} \mathbb{R} \setminus \mathbb{Q}, \ \ \ \ x=\frac{a}{b} \text{ and } a + b = \text{even} \\ \mathbb{Q}, \ \ \ \ \ \ \ \ \ \ \ x \not\in \mathbb{Q} \text{ and } a + b = \text{odd} \end{cases}$$

for $x$ being irrational it doesn't need to follow any specific rule besides being continuous.

and for $x=0$ the simple fraction is $\frac{0}{1}$ so $f(0)$ is rational

1

There are 1 best solutions below

3
On BEST ANSWER

How about

$$f(x)= \begin{cases} 0\quad\text{if }x\not\in\mathbb{Q}\\ \displaystyle{(-1)^a+(-1)^b\over b}\pi\quad\text{if }x=a/b\in\mathbb{Q}\text{ (with }\gcd(a,b)=1\text{ and }b\ge1) \end{cases}$$