TITLE: Is showing that $x_n \rightarrow x_0\Rightarrow f(x_n) \rightarrow f(x_0)$ for a single sequence enough to prove continuity?
QUESTION [22 upvotes]: For all my homework in real analysis, when I've been asked to show that a function is continuous, I just found a single $x_n \in D$ and showed that when $x_n \rightarrow x_0$, $f(x_n) \rightarrow f(x_0)$. Apparently, the sequence definition (as opposed to the epsilon delta definition) is (basically) only used to prove a function is not continuous, and I can't prove a function is continuous because then I'd have to show this is true for all possible sequences? Am I doing the math wrongly? Should I always use the epsilon delta definition when trying to prove that a function is continuous?

REPLY [35 votes]: This is indeed incorrect. Take for example the function 
$$f(x) = \begin{cases}
1, \text{ if } x\in \mathbb{Q}\\
0, \text{ otherwise}
\end{cases}$$ 
This is obviously not a continuous function. However, if you look at its behavior along a sequence of rational points, it would appear to be constant (hence continuous).

REPLY [9 votes]: What everyone said is true. But I'd like to say a few more things. Like what the other commenters wrote, if you want to prove $f:D \rightarrow \mathbb{R}$ is continuous, you need to say "Let $x_0 \in D$ and let $(x_n)$ be a sequence in $D$ that converges to some $x_0$." $(x_n)$ in this proof is an abstract concept: it's simply an arbitrary sequence in $D$. It's not anything special or specific, it's just some regular sequence that happens to converge to $x_0$.
From there, you have to use the mathematics of sequences, convergence, properties given to you on the problem to logically walk from the statement "$\lim x_n = x_0$" to "$\lim f(x_n)=f(x_0)$." Remark you can't use the properties of any specific sequence, such as $(x_0+\frac{1}{n})_n$.
You also asked if you should always use $\epsilon-\delta$ definitions. So remember I implied you have to play around with the mathematics of sequences, convergence, etc. for arbitrary sequences. This same goes for $\epsilon-\delta$ definitions. Trying to prove a function is continuous by using an actual specific sequence is like trying to prove a function is continuous by setting $\epsilon=1$ and showing there exists some $\delta>0$ such that $|f(x)-f(x_0)|<1$ whenever $x \in D$ and $|x-x_0|<\delta$. Like...congrats. You did it for $\epsilon=1$, but you didn't do it for $\epsilon=2$. You didn't do it for $\epsilon>0$. It's just for $\epsilon-\delta$ definitions, the idea of using arbitrary $\epsilon$'s and $\delta$'s is really obvious compared to the sequence definition. However the idea is still the same: you have to be abstract and arbitrary. I hope this helped.