prove $x \mapsto x^2$ is continuous

I am to show the continuity of this function with the help of $\epsilon$-$\delta$ argument.

The function is: $g: \Bbb{R} \rightarrow \Bbb{R}$, $x \mapsto x^2$.

Given the $\epsilon$-$\delta$ definition of limit, I tried as follows:

We must have: $|f(x)-f(x_0)|<\epsilon$, so then $|x^2-x_0^2|=|(x-x_0)(x+x_0)|=|(x-x_0)||(x+x_0)|$, so $|x-x_0|<\frac{\epsilon}{|x+x_0|}$. So now I will choose $\delta=\frac{\epsilon}{|x+x_0|}$.

Is it enough? I am writing this sentences like a machine, but I am not understanding intuitively.


No. $\delta$ must only depend on $x_0,\epsilon$ and never on $x$. Here is what we will do:

The problematic term is $\left|x+x_0\right|$. We have that \begin{equation} \left|x+x_0\right|= \left|x-x_0+2x_0\right|\le \left|x-x_0\right|+\left|2x_0\right|<\delta+2\left|x_0\right|\end{equation} Thus, \begin{equation}\left|x-x_0\right|<\delta\implies \left|f(x)-f(x_0)\right|=\left|x+x_0\right|\left|x-x_0\right|<(\delta+2\left|x_0\right|)\delta\end{equation} We must choose a $\delta$ so that $$(\delta+2\left|x_0\right|)\delta<\epsilon$$ Choosing a $\delta$ by the above might be complicating. But because $\delta$ is ours to choose we can simplify things a bit by demanding $\delta<1$. Then, $$(\delta+2\left|x_0\right|)\delta<(1+2\left|x_0\right|)\delta$$ and so it suffices to choose $0<\delta<1$ so that $$(1+2\left|x_0\right|)\delta<\epsilon$$ Things should be straighforward now.

For the sake of completion we have $$(1+2\left|x_0\right|)\delta<\epsilon\iff \delta<\frac{\epsilon}{1+2\left|x_0\right|}$$ But because $\delta<1$ we must choose $\delta>0$ so that $$\delta<\min\left\{1,\frac{\epsilon}{1+2\left|x_0\right|}\right\}$$ Taking $$\delta=\frac12\min\left\{1,\frac{\epsilon}{1+2\left|x_0\right|}\right\}$$ completes the proof