Investigating Continuity of Dirichlet and related functions: An $\epsilon-\delta$ approach I have trouble proving discontinuity of the Dirichlet function, using the $\epsilon-\delta$ approach. 
The function is defined as follows:
$$   f(x) = \left\{\begin{array}{l l}     1 &\text{if }x \in \mathbb{Q} \\     0 & \text{if } x \notin \mathbb{Q}   
\end{array} \right. $$
Would it do any good showing the discontinuity at some $x_0$, by bifurcating the problem into two cases, one where $x_0$ is rational and one where it isn't?
The above function isn't continuous anywhere, but let's look at one that is continuous at only one point in its entire domain:
$$   f(x) = \left\{\begin{array}{l l}     0 &\text{if }x \in \mathbb{Q} \\     x & \text{if } x \notin \mathbb{Q}   
\end{array} \right. $$
I can see that this function is continuous at 0 alone, but once again, not able to show it rigorously by picking an appropriate $\epsilon$.
How should I go about investigating the continuity of such "weird" functions, using $\epsilon-\delta$ arguments? I'm sure there are many more to add to my troubles, such as Thomae's function, for instance. I'm really more concerned with the approach than with the solution, though it'd be great if someone could help me figure out proper proofs for the above functions, so I can at least get started from where I ended up getting stuck (all the functions look pretty similar in that sense, and knowing how to work with $\epsilon-\delta$ with even one should help me figure out the rest)
Please help me out, I'm pretty new to real analysis! Thanks a lot in advance!
 A: Remember what epsilon-delta continuity is: anytime someone gives an epsilon, you have to respond with a delta that works if you want to prove your function is continuous. Sometimes the strategy can feel a little contrived, but imagining this sort of game can be a real help. When dealing with strange functions, think about the "special features" of your function - what makes it unique? It will take you some time to get used to this, but with practice, you will develop your intuition.
For the first problem, there's no need to use caserwork: it is possible to pick an epsilon so that there is no valid response of delta. Can you think of what it is?
Hint:

  The rationals and irrationals are both dense in the reals - this means for any open set, there's a rational and an irrational in it. Put another way, for any $x\in\Bbb R$ and any $\eta>0$, there's both rational and irrational $y$ so that $x<y<x+\eta$ (and similarly for $x-\eta<y<x$).

Bigger hint:

 What happens when you pick $\epsilon = \frac12$?

For the second problem, think again about what you need to do. If you're at zero and someone gives you an epsilon, do you see a choice of delta so that $f(x)$ will be less than $\epsilon$ for all $x$ with $|x|<\delta$?
Big hint:

 What happens when you take $\delta=\epsilon$?

A: First, let us look at the $\epsilon-\delta$ definition of continuity. If $f$ is a real valued function, then it is said to be continuous at a point $x_0 \in \mathbb{R}$ if
$$\forall \epsilon > 0, \exists \delta > 0 \text{ such that } \forall x \in \mathbb{R} \text{ with } \left| x - x_0 \right| < \delta, \text{ we have } \left| f \left( x \right) - f \left( x_0 \right) \right| < \epsilon$$
Therefore, if we want to prove that a function is NOT continuous, then just have to find an $\epsilon$ so that no matter what $\delta$ we choose, we can have $\left| x - x_0 \right| < \delta$ and $\left| f \left( x \right) - f \left( x_0 \right) \right| \geq \epsilon$.
So, first let us look at the Dirichlet function $f: \mathbb{R} \rightarrow \mathbb{R}$,
$$f \left( x \right) = \begin{cases}
1, & x \in \mathbb{Q} \\
0, & x \notin \mathbb{Q}
\end{cases}$$
Our guess is that it is not continuous at any point in $\mathbb{R}$. So, let $x_0 \in \mathbb{R}$ be arbitrarily chosen. If $x_0$ is rational, then $f \left( x_0 \right) = 1$, otherwise $f \left( x_0 \right) = 0$. First, let us see what happens when $x_0$ is rational.
Since the function does not take any value between $0$ and $1$, let us choose $\epsilon = \dfrac{1}{2}$ and let $\delta > 0$ be arbitrary. Now, consider all those $x \in \mathbb{R}$ such that $\left| x - x_0 \right| < \delta$. In other words, $x_0 - \delta < x < x_0 + \delta$.
Since $\delta > 0$, $x_0 - \delta < x_0 + \delta$ so that by the density of irrationals in $\mathbb{R}$, $\exists x \in \mathbb{R} \setminus \mathbb{Q}$ such that the above inequality holds. Now, $f \left( x \right) = 0$ so that $\left| f \left( x \right) - f \left( x_0 \right) \right| = 1 > \dfrac{1}{2}$. Hence, if $x$ is rational, the function is discontinuous.
Similar arguments can be made to prove the discontinuity of Dirichlet function at an irrational point so that it is nowhere continuous.
Based on this approach, I hope that you can prove the continuity/discontinuity of the other function specified in the question.
A: For Dirichlet function, do you understand that $\mathbb{Q}$ is dense in $\mathbb{R}$? If so, you will find the function is discontinuous for every point just by $\epsilon-\delta$ approach. For the second function, you can just pick any $\epsilon$, then pick $\delta=\epsilon$, for $x\in(-\delta,\delta)$, if $x$ is rational, $f(x)=0<\epsilon$, if $x$ is irrational, $|f(x)-0| = |x|<\epsilon$. Hence, by the approach, the function is continuous at $0$.
