If $f(x)=\sin(x)$, when $x$ is rational and $f(x)=\cos(x)$, when $x$ is irrational, will it be continuous at $x=n \pi+\frac{\pi}{4}$ Here $n$ is any integer. This is my attempt at solving the question:
Since $n \pi+\frac{\pi}{4}$ is irational, $f(x)=\cos(x)$. Let $h$ be a infinitesimally small positive quantity and $n=1$
$$
RHL=\lim\limits_{h\rightarrow0}f\left(\frac{\pi}{4}+h\right)$$
$$LHL=\lim\limits_{h\rightarrow0}f\left(\frac{\pi}{4}-h\right)$$
This is where my confusion begins, if we assume $h$ to be an infinitesimally small irrational number in the first case and infinitesimally small rational number in the second case then the function will be discontinuous.
If we assume $h$ to be an infinitesimally small rational number in the first case and infinitesimally small rational number in the second case then the function will be continuous.
However If we assume $h$ to be an infinitesimally small irrational number in the first case and infinitesimally small irrational number in the second case then the function will be discontinuous. So how can a function like this exist, and where am I going wrong?
 A: Let $x_n = n \pi + \frac{\pi}4$. Note that
$$\sin x_n = \cos x_n=\frac{(-1)^n}{\sqrt 2} = f( x_n).\tag{1}\label{1}$$
So, intuitively, if you get close enough to $ x_n$ the function will approach the value $\frac{(-1)^n}{\sqrt 2}$.
More formally, fix $\varepsilon > 0$. Since $\sin x$ is continuous in in $x_n$, there exists $\delta_1$ such that
$$\left|\sin x - \frac{(-1)^n}{\sqrt 2}\right| < \varepsilon$$
for all $x$ such that $|x - x_n| < \delta_1$.
Similarly, by continuity of $\cos x$ in $x_n$, there exists $\delta_2$ such that
$$\left|\cos x - \frac{(-1)^n}{\sqrt 2}\right|< \varepsilon$$
for all $x$ such that $|x - x_n| < \delta_2$.
Now choose $\delta = \min(\delta_1,\delta_2)$ and you get
$$\left| f(x) - \frac{(-1)^n}{\sqrt 2}\right| < \varepsilon$$
for every $x$ that satisfies
$$|x-x_n| < \delta,$$
which implies, together with \eqref{1}, continuity of $f$ in $x_n$.
A: Since the point $n\pi+(\pi/4)$ under consideration, say $a$, is irrational we have $f(a) =\cos a$ and thus $$|f(x) - f(a) |=|\sin x - \cos a|=|\sin x - \sin a|$$ as $\cos a =\sin a$ when  $x$ is rational and $$|f(x) - f(a) |=|\cos x-\cos a|$$ if $x$ is irrational.
Now observe that both the differences $|\sin x-\sin a|$ and $|\cos x - \cos a|$ never exceed $|x-a|$. Why??
Well, $$|\sin x - \sin a|=|2\cos((x+a)/2)\sin((x-a)/2)|\leq 2|(x-a)/2|=|x-a|$$ and similarly one can handle the other difference.
Hence $$0\leq |f(x) - f(a) |\leq |x-a|$$ If you are aware of definition of limit then the above inequality allows you to take $\delta =\epsilon $ and show that $\lim_{x\to a} f(x) =f(a) $.
On the other hand if you are not aware of definition of limit you can use Squeeze theorem to conclude $\lim_{x\to a} f(x) =f(a) $. And therefore the function is continuous at all points $a$ of the form $a=n\pi+(\pi/4)$.
