Define $g: \mathbb{R} \to \mathbb{R}$ by $$g(x) =\begin{cases} x^2 & \text{if } x \text{ is rational}, \\\\ x^4 & \text{if } x \text{ is irrational}. \end{cases}$$ Prove that $g$ is continuous at $x = 0$ using $\epsilon - \delta$ definition of continuity.
Is my solution correct?
Solution Attempt:
Let $\epsilon > 0 $
$\lim _{x\to\:a}\:x^{2\:}=\:a^2,\:a=0$
$\left|x^2-a^2|\:=\:\right|x+a\left|\right|x-a\left|\right|$
Suppose $\:\left|x-a\right|<1$
then, $-1<x-a<1 \iff -1+a<x<1+a $
Since $|x+a| \leq |x| + |a|$ , we have $ |x+a| < (2a+1) $
So, $\left|x^2-a^2|\:=\:\right|x+a\left|\right|x-a\left|\right| < |x-a| (2a+1)$
Let $\delta = $ min {$1, \frac{\epsilon}{2a+1}$}
If $|x-a| < \delta$, then
$\left|x^2-a^2|\:=\:\right|x+a\left|\right|x-a\left|\right| < |x-a| (2a+1) < \frac{\epsilon}{2a+1} (2a+1) = \epsilon.$
Let $\epsilon >0$.
$g(0)=0$;
For $|x| <1$:
$|x|^4 \le |x|^2 \le |x|$
Choose $\delta = \min (\epsilon, 1)$.
Then
$|x| \lt \delta$ implies
$|g(x)-g(0)| =|g(x)| \le |x| \lt \epsilon.$