Take the counterexample$$ -1 \le \sin(x^2) \le 1 \quad \forall x \in \mathbb{R}, $$
but the function $h(x) = \sin(x^2)$ is not uniformly continuous.
The required condition would be;
Let $f, g, h: \mathbb{R} \to \mathbb{R}$ be continuous functions. Suppose:
- $f$ and $g$ are uniformly continuous on $\mathbb{R}$.
- $f(x) \le h(x) \le g(x)$ for all $x \in \mathbb{R}$.
- $\lim_{|x| \to \infty} (g(x) - f(x)) = 0$.
Then $h$ is uniformly continuous on $\mathbb{R}$.
Proof:
Let $\epsilon > 0$ be given.
Since $\lim_{|x| \to \infty} (g(x) - f(x)) = 0$, there exists an $M > 0$ such that for all $|x| \ge M$:
$$|g(x) - f(x)| < \frac{\epsilon}{3}$$
Using the sandwich condition, we know $|h(x) - f(x)| \le |g(x) - f(x)|$. Thus, for $|x| \ge M$:
$$|h(x) - f(x)| < \frac{\epsilon}{3}$$
Since $f$ is uniformly continuous on $\mathbb{R}$, there exists $\delta_1 > 0$ such that for any $x, y \in \mathbb{R}$:
$$|x - y| < \delta_1 \implies |f(x) - f(y)| < \frac{\epsilon}{3}$$
Consider the compact interval $K = [-(M+1), M+1]$. Since $h$ is continuous on $K$, it is uniformly continuous on $K$ (by the Heine-Cantor theorem). Thus, there exists $\delta_2 > 0$ such that for any $x, y \in K$:
$$|x - y| < \delta_2 \implies |h(x) - h(y)| < \epsilon$$
Let $\delta = \min(1, \delta_1, \delta_2)$. Consider any $x, y \in \mathbb{R}$ with $|x - y| < \delta$.
Case 1: $x \in [-M, M]$
Since $|x - y| < 1$, $y$ must be in $[-(M+1), M+1]$. Therefore, both points are in $K$.
$$|h(x) - h(y)| < \epsilon$$
Case 2: $|x| \ge M$, $|y| \ge M$.
We use the triangle inequality, using $f$ as a bridge between $x$ and $y$:
$$|h(x) - h(y)| \le |h(x) - f(x)| + |f(x) - f(y)| + |f(y) - h(y)|$$
Substituting the bounds:
$$|h(x) - h(y)| < \frac{\epsilon}{3} + \frac{\epsilon}{3} + \frac{\epsilon}{3} = \epsilon$$
Since $|h(x) - h(y)| < \epsilon$ in all cases, $h$ is uniformly continuous.