If $x^2$ is not uniformly continuous then how does this theorem hold? I am studying Spivak's calculus. The subject uniform continuity was in an Appendix and I thought it was dull comparing to the other subjects. So I turned to the math stackexchange for more clear and intuitive explanations as usual. There are lots of questions on this site and I see lots of people like me are confused about this subject one way or another. For example,
Here: It is stated that $x^2$ is not uniformly continous on the real line.
Here: It is stated that $\delta$ cannot depend on $x$ (should depend only on $\varepsilon$) for uniform continuity. There is also a graph in answers explaining why $x^2$ is not uniformly continuous.
But here: A theorem is proved which I met while studying Spivak's calculus. The theorem states that:

If $f$ is continous on $[a,b]$, then $f$ is uniformly continuous on $[a,b]$.

Then, what about $f(x)=x^2$? We know it is continuous. If we define $x^2$ on an interval $[a,b]$, will it be uniformly continuous on [a,b] but not uniformly continuous on the real line? If we define $x^2$ on an interval, can we make $\delta$ independent of $x$ as stated as a requirement above? I am really confused what is happenning here?  
 A: Proof for you to understand and check that $\;f(x)=x^2\;$ is not u.c. on $\;[0,\infty)\;$:
$$x_n:=\sqrt n\implies |x_{n+1}-x_n|\xrightarrow[n\to\infty]{}0\;,\;\;\text{yet nevertheless}\;\;|f(x_{n+1})-f(x_n)|\rlap{\;\;\;\;\;/}\xrightarrow[n\to\infty]{}0$$
A: $\DeclareMathOperator{\sgn}{sgn}\newcommand{\Reals}{\mathbf{R}}\newcommand{\eps}{\varepsilon}$Uniform continuity is a "global" property, depending not only on the formula(s) defining a function but on the domain $X$. To see why, compare the definitions of "$f$ is continuous on $X$" and "$f$ is uniformly continuous on $X$":


*

*For every $x$ in $X$ and every $\eps > 0$, there exists a $\delta > 0$ such that if $y \in X$ and $|x - y| < \delta$, then $|f(x) - f(y)| < \eps$. (Here, $\delta$ implicitly depends on both $\eps$ and $x$; there may or may not exist a positive lower bound on $\delta$ as $x$ ranges over $X$.)

*For every $\eps > 0$, there exists a $\delta > 0$ such that if $x$, $y$ are in $X$ and $|x - y| < \delta$, then $|f(x) - f(y)| < \eps$. (Here, $\delta$ depends only on $\eps$; a single $\delta$ "works" for every $x$ in $X$. Whether or not this condition is true may depend on the set $X$.)
Consider the squaring function, $f(x) = x^{2}$, on an unspecified domain $X \subseteq \Reals$. Since
$$
|f(x) - f(y)| = |x^{2} - y^{2}| = |x - y|\, |x + y|,
$$
$f$ is uniformly continuous if $X$ is bounded: If $X \subset [-M, M]$, then $|x + y| \leq |x| + |y| \leq 2M$ on $X$ by the triangle inequality. For every $\eps > 0$ we can choose $\delta = \eps/(2M)$ to see $f$ is uniformly continuous. (Boundedness of $X$ is not necessary; think of what happens for $X = \mathbf{Z}$, the set of integers: You can take $\delta = 1/2$ no matter what function you're considering.)
Another example often surprises students the first time they see it, and may hightlight the global (domain-dependent) nature of uniform continuity: Let $X = \Reals \setminus\{0\}$, and define $\sgn:X \to \Reals$ by
$$
\sgn(x) = \frac{x}{|x|}
  = \begin{cases}
  1 & \text{if $x > 0$,} \\
 -1 & \text{if $x < 0$.}
\end{cases}
$$
The function $\sgn$ is locally constant: For every non-zero $x_{0}$, $\sgn$ is constant on the open interval with endpoints $0$ and $2x_{0}$; that's "as continuous as you can get", pointwise.
But $\sgn$ is not uniformly continuous on $X$: For every $\delta > 0$, the points $x = -\delta/3$ and $y = \delta/3$ satisfy $|x - y| < \delta$, but are of opposite sign, so $|\sgn(x) - \sgn(y)| = 2$.
I leave to you the fun of analyzing the same formula on the set $\Reals\setminus[0, 0.0001]$ obtained by removing an interval of positive length that contains $0$.
A: What you said is exactly right, that $\delta$ can be selected independently on bounded intervals but not on unbounded ones.  You have the picture from your link you consider, but if you want more what you should think about is this - for $x^2$ the $\delta$ you need to use becomes smaller (to $0$) based on the size of the interval.  For a bounded interval this means you can pick a definite $\delta$, but for an unbounded one you would use "$\delta = 0$" which of course doesn't work.
I'm sure there is a more elegant way to see this, but this can be observed from calculus.
$$|x^2-x_0^2| = |x-x_0||x+x_0|$$
So, by the mean value theorem there is a $c$ between $x$ and $x_0$ obeying
$$|2c| = \frac{|x^2 - x_0^2|}{|x-x_0|} = |x+x_0|$$
Suppose we had a way to pick $\delta$ based on $\epsilon$ so that $|x-x_0| < \delta$ ensures $|x^2-x_0^2\ < \epsilon$ for any $x_0$.  Well, then we would have
$$2|c||x-x_0| = |x+x_0||x-x_0| = |x^2 - x_0^2| < \epsilon$$
But this means
$$\delta = |x-x_0| < \frac{\epsilon}{2|c|}$$
And as $x_0 \to \infty$ the right side goes to $0$, since $c$ lives near $x_0$.
