The function f(x) is defined by:
f(x)=x, if x is rational
f(x)=2x, if x is irrational
Is f continuous?
Now my answer was the following: let a=√2 (any irrational number would do). Then f(a)=2√2. But, as x gets arbitrarily close to a, x is rational, so lim(x->a) of f(x)=√2, which is not equal to f(a), so f is not continuous.
Are there any flaws in my proof? My main question is, can we safely assume that x is rational as we let it get arbitrarily close (but not equal) to a? Thanks in advance, and excuse my failure to use MathJax, but I cannot for the love of me get the mathematical notations to appear.
Your proof is not quite correct. In particular, the statement "as $x$ gets arbitrarily close to $a$, $x$ is rational" is not correct. In fact, no matter how close $x$ gets to $a$, there will always be rational and irrational numbers between $x$ and $a$.
For $f$ to be continuous at a point $x=a,$ we would need $\lim_{x\to a}f(x)=f(a)$. That means that for all $\epsilon > 0$, there must be a $\delta>0$ such that if $x\in(a-\delta, a+\delta)$, $f(x)\in (f(a)-\epsilon, f(a)+\epsilon)$. This clearly cannot happen in this case because any interval $(a-\delta,a+\delta)$ contains rational and irrational numbers, so the values of $f(x)$ cannot all be within $\epsilon$ of $f(a)$ (whether $a$ is rational or irrational).
Let's see what this would look like for your choice of $a= \sqrt{2}$ with $f(a)=2\sqrt{2}$. Let $\epsilon=\sqrt{2}$. For any $\delta>0$, the interval $(a-\delta,a)$ contains a rational number, call it $q$. Then $$f(a)-f(q)=2\sqrt{2}-q>2\sqrt{2}-\sqrt{2}=\sqrt{2}=\epsilon$$