Why a continuous but not uniformly continuous function $f$ in $\mathbb{R}^n$ becomes uniformly continuous when the domain restricted to a compact set? I've seen the proof of the title and roughly follow every steps of the proof. But I cannot see the intuition of this statement. Could someone show me a concrete example using $\delta-\epsilon$? Thanks!
 A: Let me give you some examples that may help to form the intuition about compact sets. Although these examples will be functions on $\Bbb R$, the idea for $\Bbb R^n$ is not that different.
By the Heine-Borel theorem, compact sets in $\Bbb R^n$ are precisely those that are closed and bounded. Let's see what happens when these $2$ conditions are not satisfied.
Closed: Strong oscillation is one reason that prevents a continuous function from being uniformly continuous. Consider the continuous function $f:(0,1]\to\Bbb R$ defined by
$$
f(x)=\sin\left(\frac 1x \right).
$$
This function is not uniformly continuous because the oscillation becomes infinitely strong near $x=0$. This happens because $x=0$ is on the boundary of $(0,1]$ but $f(0)$ need not be defined, hence the behaviour of $f$ can be very wild near the boundary points. On the other hand, if our domain is compact, says $D=[0,1]$ then $f(0)$ must be defined so the oscillation near $x=0$, if there is any, must "dies out" fast enough so that $\lim_{y\to 0}f(y)=f(0)$.
Bounded: Steepness is another reason that a function can fail to be uniformly continuous. Consider $f:[0,\infty)\to \Bbb R$ befined by 
$$
f(x)=x^2.
$$
Suppose that $a<b$. By the mean value theorem, we have $|f(a)-f(b)|=|f'(\xi)||a-b|$ for some $\xi\in(a,b)$. We know that $f'(x)=2x$ and that our domain is not bounded, thus $f'(\xi)$ is unbounded too. This implies that $f$ is not uniformly continuous. If, however, our domain is bounded, says $D=[0,M]$, then $f'(x)$ is bounded and our function must be uniformly continuous.
In general, $f$ need not be differentiable so the above reasoning doesn't apply literally. Still, I hope that gives some intuition that might help. The situation is also related to the extreme value theorem, i.e. that a continuous function cannot be unbounded on a compact set.
A: If for say $\epsilon=1$ there's no $\delta$ that works in the entire compact set, then let $x_n$ be such that $\delta=1/n$ doesn't work. Then an accumulation point of the $x_n$ is a point where $f$ is not continuous at all.
A: A concrete example can be as follows. Take e.g. $f(x) = x^2$. That is a continuous function on $\mathbb{R}$, but it is not uniformly continuous because $|f(y) - f(x)| = |y^2 - x^2|$ cannot be kept smaller that a given $\varepsilon>0$ for every $x,y$ whose difference $|y-x|$ is less that a given $\delta_{\varepsilon}$ depending only on $\varepsilon$ but not on $x,y$. In other words, there is no $\delta_{\varepsilon}>0$ such that $|y-x| < \delta_{\varepsilon}$ implies $|f(y) - f(x)| = |y^2 - x^2| < \delta_{\varepsilon}$, because $|y^2 - x^2| = |x+y||x-y|$, and it does not matter how small $|x-y|$ is, the other factor $|x+y|$ can be made large enough (by picking $x,y$ large) so that $|y^2 - x^2| \geq \delta_{\varepsilon}$. However, a compact set of $\mathbb{R}$ such as the interval $[0,1]$ is bounded, and that makes the factor $|x+y|$ also bounded, more specifically $|x+y| \leq 2$ on $[0,1]$. So now we can find a $\delta_{\epsilon} = \frac{\varepsilon}{2}$ such that $|y-x| < \delta_{\varepsilon}$ implies
$$|y^2 - x^2| = |x+y||x-y| < 2 \delta_{\varepsilon} = 2 \cdot \frac{\varepsilon}{2} = \varepsilon$$
Edit: By the time I finished writing my answer I found that BigbearZzz had already posted a more complete answer. I'll post mine anyway as a simpler version, and using $\varepsilon-\delta$ as requested by the OP.
A: Consider $f(x)=\frac{1}{x}$ which is continuous on $(0,\infty)$ but not uniformly so.
Why can't we find one $\delta\gt 0$ that works for all $x\in (0,\infty)$? As $x$ gets closer to $0$, $\ f$ gets steeper so that small changes in $x$ lead to larger changes in $f$.
Suppose we are given $\epsilon\gt 0$ and $a\in(0,\infty)$. We want to find $\delta\gt 0$ such that $|x-a|\lt\delta\implies|\frac{1}{a}-\frac{1}{x}|\lt\epsilon$.
$$|\frac{1}{a}-\frac{1}{x}|\lt\epsilon\implies -\epsilon\lt\frac{1}{a}-\frac{1}{x}\lt\epsilon\implies -\frac{1}{a}-\epsilon\lt -\frac{1}{x}\lt\epsilon-\frac{1}{a}\implies\frac{1}{a}+\epsilon\gt\frac{1}{x}\gt\frac{1}{a}-\epsilon$$
The right hand side is equivalent to $\frac{1+a\epsilon}{a}\gt\frac{1}{x}\gt\frac{1-a\epsilon}{a}$. 
If $\epsilon$ is large enough that $1-a\epsilon\lt 0$, we can restrict $\epsilon$ to be smaller so that $1-a\epsilon\gt 0$. We can do this because if the absolute value is less than the smaller $\epsilon$ then it must also be less than the larger $\epsilon$.
Restricting $\epsilon$ and taking reciprocals gives us $\frac{a}{1+a\epsilon}\lt x\lt\frac{a}{1-a\epsilon}$.
For small $\epsilon$, $\ \frac{a}{1+a\epsilon}$ is a number slightly smaller than $a$ and $\frac{a}{1-a\epsilon}$ is a number slightly larger than $a$. Therefore, as $a$ gets closer to $0$, we require a smaller $\delta$ to make $|\frac{1}{a}-\frac{1}{x}|\lt\epsilon$.
