# Piecewise function, prove function is continuous at 0

Consider the piecewise function: $$f(x)=\begin{cases} x & \text{if x is rational}\\ -x & \text{if x is irrational} \end{cases}$$

This produces a function that jumps rapidly between $x$ and $-x$ throughout its graph. It can be shown that this function is discontinuous for all nonzero values of $x$. I do not need to prove this, but I do need to prove that this function is continuos at $0$.

• $\lim_{x \to 0} f(x) = 0$, since $|f(x)| = |x|$, and $f(0) = 0$ – Nick Feb 3 '17 at 22:12

$$\forall \epsilon \exists \delta >0 :|x-x_0|<\delta \Rightarrow |f(x)-f(x_0)|<\epsilon\\ |x-0|<\delta \Rightarrow |f(x)-f(0)|<\epsilon\\ |x|<\delta \Rightarrow |\pm x-0|<\epsilon \\ |x|<\delta \Rightarrow |\pm 1||x|<\epsilon\\\delta <\epsilon$$

$|f(x)-f (0)|=|x|$.