$f(x)= \begin{cases} -1+\sin(k_1\pi x) & x\;\text{is rational} \\ 1+\cos(k_2 \pi x) & x\;\text{is irrational} \end{cases}$
If $f(x)$ is periodic function, then
(A) Either $k_1, k_2\in\text{rational} \;\text{or}\;k_1, k_2\in\text{irrational}$
(B) $k_1, k_2\in\text{rational only}$
(C) $k_1, k_2\in\text{irrational only}$
(D) $k_1, k_2\in\text{irrational such that }\dfrac{k_1}{k_2}\; \text{rational}$
My Approach:
Case $(1)$: Assuming Period $T_1$ to be rational
Let $x$ is rational
Then $f(x)=f\left(x+T_1\right)\implies -1+\sin(k_1\pi x)=-1+\sin\left(k_1 \pi(x+T_1)\right)$
$\implies \sin(k_1\pi x)=\sin\left(k_1 \pi(x+T_1)\right)$
$\implies k_1\pi (x+T_1)=n\pi+k_1\pi x\implies k_1(x+T_1)=n+k_1x\implies k_1=\dfrac{n}{T_1}$
Hence $k_1$ should be rational.
Case$(2)$:
Assuming Period $T_1$ to be irrational.
Let $x$ is rational and using the same steps as Case$(1)$ I got $k_1=\dfrac{n}{T_1}$
Hence $k_1$ should be irrational.
I am not getting any option and correct answer given is option (B)
Also, Did I make any error in Case $(2)$?
What you have shown are the following:
You do not know if $T_1$ can be either rational or irrational.
In fact, you can show that $T_1$ cannot be irrational. Indeed, if $T_1$ is the period of $f$, then we have $f(0) = f(T_1)$. However, if $T_1$ were to be irrational, then by definition of $f$, we would get $f(0) = -1 + \sin(0) = -1$ and $f(T_1) = 1 + \cos(k_2 T_1 \pi) \in [0,2]$. Therefore, they cannot be equal.