I'm given the function: $f(x)=\left\{ \begin{array}{lr} -x & : x \in \mathbb{Q}\\ x+2 & : x \notin \mathbb{Q} \end{array} \right.$
How would I (at least go about starting to) prove that $f$ is continuous at $a$ iff $a=-1$?
I'm given the function: $f(x)=\left\{ \begin{array}{lr} -x & : x \in \mathbb{Q}\\ x+2 & : x \notin \mathbb{Q} \end{array} \right.$
How would I (at least go about starting to) prove that $f$ is continuous at $a$ iff $a=-1$?
Take the limit as $x\to -1$ along both the irrationals and the rationals, and see if it jives with the actual value $f(-1)$.
Sorry, didn't put enough detail: then try this for any point $a\neq -1$ and see how successful it is.
Since $-1\in \mathbb{Q}$, f(-1)=1.
You have to see now that $\displaystyle{\lim_{h\rightarrow -1}} f(h)=-1$.
Intuitively, notice that when $h$ approaches to a value $a$, in general the value of $f(h)$ will change in a neighbourhood of $a$, depending on wether $h$ is rational or not. However, when $a=-1$, $f(h)$ will be as close as you want to $f(-1)=1$ when $h$ is sufficiently near to $-1$, since if $h$ is rational $f(h)=-h$ is close to $1$ and if $h$ is not rational $f(h)=h+2$ will also be close to $1$.
Take $\epsilon > 0$. Since $\displaystyle{\lim_{x\rightarrow -1}} -x =1$, $\exists \delta_1>0:|-x-1| = |x+1|<\delta_1 \Rightarrow |1+x| < \epsilon$. On the othe hand, $\displaystyle{\lim_{x\rightarrow -1}} x+2 =1$, so $\exists \delta_2>0:|x+1|<\delta_1 \Rightarrow |x+2-1|=|x+2| < \epsilon$.
Then, clearly taking $\delta = \delta_1 = \delta_2 = \epsilon$, both condition are fulfilled, and the limit of $f$ when $x \rightarrow -1$ is 1.
$f(x)=\left\{ \begin{array}{lr} -x & : x \in \mathbb{Q}\\ x+2 & : x \notin \mathbb{Q} \end{array} \right.$
We claim that $f$ is continuous at $-1$, i.e., $\lim_{x\to-1} f(x)=f(-1)=1$.
Given $\varepsilon>0$, let $\delta=\varepsilon$. If $x$ is rational then $|x+1|=|-x-1|=|f(x)-1|<\varepsilon$. If $x$ is irrational then $|x+1|=|x+2-1|=|f(x)-1|<\varepsilon$. Thus for all $x\in \mathbb{R}$, such that $|x+1|<\delta=\varepsilon$ we have $|f(x)-1|<\varepsilon$ as desired.
Now suppose that $x_0\not= -1$. It will suffice to show that the limit doesn't exist.
Suppose to the contrary that $\lim_{x\to x_0} f(x)=L$. Let $\varepsilon=|x_0+1|/4$, so there is a $\delta>0$ such that $|f(x)-L|<\varepsilon$ whenever $|x-x_0|< \delta$. Let $|x-x_0|<\min\big( \delta,|x_0+1|/4\big)$. So $|x+1|=|x_0+x+1-x_0|\ge |x_0+1|-|x-x_0|>|x_0+1|/2$, i.e., $|x_0+1|<|2x+2|$
If $x'$ is rational so $|x'+L|< \varepsilon$ and if $x$ is irrational $|x+2-L|<\varepsilon$. Let $x$ irrational, $x'$ rational and both satisfying $|x-x_0|<\min\big( \delta,|x_0+1|/4\big)$. Thus
$|x_0+1|<|2x+2|=|x+2-L+L+x+x'-x'+x_0-x_0|$ \begin{align}\le |x+2-L|+|L+x'|+|x-x_0|+|x_0-x'|<2\varepsilon+|x_0+1|/2\\<|x_0+1|/2+|x_0+1|/2\\ =|x_0+1| \end{align}
a contradiction. Since the limit does not exists for $x_0\not= -1$, then $f$ is not continuous in these points.
I you're not sure about the definition of limits, see my answer here. You have to use the definitions of limits and continuity. First, a function is continuous at $a$ iff: $$ \lim_{x \rightarrow a}{f(x)} = f(a) $$
To show this, you should use the $\epsilon, \delta$-definition of a limit: $$ \lim_{x \rightarrow a}{f(x)} = c $$ iff $$ \forall \epsilon \exists \delta \forall x \ |x - a| < \delta \rightarrow |f(x) - c| < \epsilon $$
I suppose you know how proofs using the $\epsilon, \delta$-definition work. Take $a = -1$ and $c = f(-1) = 1$
Suppose $\delta = \epsilon$. We need to distinguish between two cases, $x$ is rational and $x$ is irrational. Suppose $x$ is rational.
Then $|x - a| = |x + 1| < \delta \rightarrow |-(x + 1)| = |-x - 1| = |f(x) - c| < \delta = \epsilon$
If $x$ is irrational, we have (still using $\delta = \epsilon$): $|x - a| = |x + 1| < \delta \rightarrow |(x + 2) - 1| = |f(x) - c| < \delta = \epsilon$
So, in summary, we have: $|x + 1| < \delta \rightarrow |f(x) - 1| < \epsilon$ when $\delta = \epsilon$. So $\lim_{x \rightarrow -1}{f(x)} = f(-1)$, so $f$ is continuous at $-1$.
Then, showing that $f$ is not continuous at all other points may be a little more complicated. There are several strategies to show that. The most rigorous but also the most involved is to use the negation of the limit definition.
A more loose approach is either to construct a sequence of points $(x_n)$ such that $\lim_{n \rightarrow \infty}{x_n} = a$ but $\lim_{n \rightarrow \infty}{f(x_n)} \not= f(a)$, or contstruct two sequences $(x_n)$ with the same limit, but where the two sequences $f(x_n)$ have a different limit. That way you show that $lim_{x \rightarrow a}{f(x_n)}$ doesn't exist, so $\lim_{x \rightarrow a}{f(x)} = c$ does not hold for any $c$ (so also not for $c = f(x)$).
You could do a proof using the negation of the $\epsilon, \delta$ definition (you would have to prove the negation of $\lim{x \rightarrow a}{f(x)} = c$ for every $c$), but I think this way is more elegant. Most mathematicians avoid proofs using the $\epsilon, \delta$ definition when they can, because it tends to make things more complicated than necessary.
Weierstrass definition of continuity: $$(\forall \epsilon > 0,\, \exists \delta > 0,\forall x)\, \bigg(|x - a| < \delta\bigg) \rightarrow \bigg(|f(x) - f(a)| < \epsilon\bigg)$$
Cases for rationality of $x$:
$$(\forall \epsilon > 0,\, \exists \delta > 0)\\ \left( \begin{array} {cc} (\forall x \in \mathbb{Q})\, \bigg(|x - a| < \delta\bigg) \rightarrow \bigg(|f(x) - f(a)| < \epsilon\bigg)\\ \land\\ (\forall x \not\in \mathbb{Q})\, \bigg(|x - a| < \delta\bigg) \rightarrow \bigg(|f(x) - f(a)| < \epsilon\bigg) \end{array}\right)$$
Defintion of $f$, further divided into cases of $a$ being rational or not rational:
$$(\forall \epsilon > 0,\, \exists \delta > 0)\\ \left( \begin{array} {cc} (\forall x \in \mathbb{Q})\, \bigg(|x - a| < \delta\bigg) \rightarrow \bigg(|-x + a| < \epsilon\bigg)\\ \land\\ (\forall x \not\in \mathbb{Q})\, \bigg(|x - a| < \delta\bigg) \rightarrow \bigg(|x + 2 + a| < \epsilon\bigg)\\ \land\\ (\forall x \in \mathbb{Q})\, \bigg(|x - a| < \delta\bigg) \rightarrow \bigg(|-x - a - 2| < \epsilon\bigg)\\ \land\\ (\forall x \not\in \mathbb{Q})\, \bigg(|x - a| < \delta\bigg) \rightarrow \bigg(|x + 2 - a - 2| < \epsilon\bigg) \end{array}\right)$$
Simplifying: $$(\forall \epsilon > 0,\, \exists \delta > 0)\\ \left( \begin{array} {cc} \delta \le \epsilon \\ \land\\ (\forall x)\, \bigg(|x - a| < \delta\bigg) \rightarrow \bigg(|x + 2 + a| < \epsilon\bigg) \end{array}\right)$$
The $\delta \le \epsilon$ term was expected, because the slope of the functions is $\pm 1$. I believe you can see that if $a = -1$, the above $\exists$ is satisfied by any $\delta \le \epsilon$.
So we wish to show that $a \ne -1$ cannot satisfy the $\exists$:
$$(a \ne -1, \exists \epsilon > 0,\, \forall \delta > 0)\\ \left( \begin{array} {cc} \delta > \epsilon \\ \lor \\ (\exists x)\, \bigg(|x - a| < \delta\bigg) \land \bigg(|x + 2 + a| \ge \epsilon\bigg) \end{array}\right)$$
That was demorgans. Simplify:
$$(a \ne -1, \exists \epsilon, \forall 0 < \delta \le \epsilon)\\ \left( \begin{array} {cc} (\exists x)\, \bigg(|x - a| < \delta\bigg) \land \bigg(|x + 2 + a| \ge \epsilon\bigg) \end{array}\right)$$
To satisfy the $\exists x$, solve the simultaneous equations for $x$: $$ |x - a | < \delta \le \epsilon \le |x + 2 + a |\\ $$
which is a pain. Let $y = x-1$, $a = p -1$, solve for $y$: $$ |y - p| < \delta \le \epsilon \le |y + p|\\ $$
$$\begin{cases} p \ne 0\\ y \in (\delta - |p|, \delta + |p|)\\ y \not \in (-\epsilon - p, \epsilon + p)\\ \end{cases}$$
So for some $\epsilon$ where the second range doesn't contain the first range, $y$ exists,so $a = -1$ cannot satisfy the Weierstrass definition continuity.