Suppose $f(x) = \begin{cases} 0, & \text{if x is rational},\\ x^2, & \text{if x is irrational} \end{cases}$. Prove that $\lim_{x\to 0} f(x) = 0$

Suppose $f(x) = \begin{cases} 0, & \text{if x is rational},\\ x^2, & \text{if x is irrational} \end{cases}$

Prove that $\lim_{x\to 0} f(x) = 0$

Edit:

My attempt below, though I'm not sure if this approach is correct from the on-set.

For irrational $x$:

$\lim_{\delta x\to 0} f(x) = \frac{d}{dx} x^2 = 2x$

Hence, at $x=0$,

$\lim_{x\to 0} f(x) = \lim_{\delta x\to 0} f(0) = 2(0) = 0$ (proved?)

What about for rational $x$? o.O

My background: I don't have a degree in math, just an undergrad training in engineering. Not sure where the question was referenced from exactly too, but I would peg it at around high school AP/freshmen level. I'm asking this out of an interest in the topic.

• You may had written it in better form: Show that $f$ is continuous and differentiable only at $0$ with limit and derivative $0$ – Groups Oct 2 '15 at 5:48

This proof is pretty easy in my opinion, and can be explained verbally (this is effectively the definition of the limit). Let's say we choose a number very close to $0$. Either the number is rational (and yields $0$), or the number is irrational (and yields a number that is very small). Thus, if we keep choosing irrational numbers closer to $0$ we approach $0$, and if we choose rational numbers close to $0$ we get $0$ exactly. Combining these, as x approaches $0$ the function approaches $0$.
Simply: compare $f(x)$ to $g(x) = 0$ and $h(x) = x^2$ and use the Squeeze Theorem.
Let $\varepsilon > 0$; then $f(x) \leq x^{2} < \varepsilon$ if $|x| < \sqrt{\varepsilon}$, so taking $\delta := \sqrt{\varepsilon}$ suffices.