# Examples of (not) uniformly continuous, non-differentiable, non-periodic functions

Let $I\subseteq\mathbb{R}$ and $f:I\to\mathbb{R}.$

$(0)$ If $f$ is discontinuous on $I$, then it is not uniformly continuous.

$(1)$ Suppose $I$ is open and bounded. If $f$ is unbounded on $I$, then it is not uniformly continuous. Otherwise, let $I=(a,b)$. If we can extend $f$ to $[a,b]$ by continuity, i.e. define $f^*(x):=\begin{cases}\lim\limits_{x\to a^+} f(x) & x=a \\ f(x) & x\in(a,b)\\ \lim\limits_{x\to b^-}f(x) & x=b\end{cases},$ $f^*$ is continuous on its domain, which is compact, and thus uniformly continuous by Heine-Cantor's theorem. Hence, so it is on $(a,b)$. If, instead, at least one of the limits above does not exist, say as $x\to a^+$, then there exist real sequences $x_n, y_n\to a^+$ such that $\lvert f(x_n)-f(y_n)\rvert\not\to0,$ implying that $f$ is not uniformly continuous.

$(2)$ If $I$ is closed and bounded, then it is compact: a trivial adaptation of $(1)$ applies.

$(3)$ Suppose $I$ is open and unbounded, say $I=(a,\infty)$; in view of $(1)$, let $f(x)\underset{x\to a^+}\longrightarrow l\in\mathbb{R}.$ If $f(x)\underset{x\to\infty}\longrightarrow L\in\mathbb{R}$ then $f$ is u.c., because, by Heine-Cantor, so is its continuous extension $\overline{f}$ to $[a,\infty]\subset\overline{\mathbb{R}}$ (similarly as in $(1)$). Otherwise, let $f$ be differentiable. If $\limsup\limits_{x\to\infty}\lvert f'(x)\rvert= \infty$ then $f$ is not u.c. by the mean value theorem, whereas if $f'$ is bounded, $f$ is lipschitzian and thus the same theorem implies u.c. Finally, assume $f'$ is unbounded on $(a,b]$ (doesn't matter if not defined on some $(\alpha,\beta]\subseteq(a,b]$) and defined and bounded elsewhere. $f$ is u.c. on $(a,b]$ because so is $f^*$ on $[a,b]$ , as well as on $(b,\infty)$, due to being lipschitzian there. By the continuity of $f$ at $b$, it suffices to make $x\in(a,b]$ and $y\in(b,\infty)$ sufficiently close to $b$ in order to have them satisfy the condition of u.c. Therefore, we conclude $f$ is u.c. on $I$.

$(4)$ If $I$ is closed and unbounded, a trivial adaptation of $(3)$ applies.

So one may note that the only functions whose uniform continuity is really interesting to investigate, are the ones defined on an unbounded interval, being globally continuous, non-periodic and non-differentiable on an unbounded subinterval of their domain. Do we know such functions, both uniformly and not uniformly continuous?

• What about continuous piecewise linear functions (i.e. joined line segments)? Jun 24, 2016 at 1:28
• @sranthrop: That may give an infinite number of points of non-differentiability, but not an unbounded interval, I believe. But I did think of piecewise functions. However, if all the "pieces" are uniformly continuous, then the "whole" can be shown to be as well simply by splitting the nasty subinterval in the nice smaller subintervals and proceed as in the last part of $(3)$. And if some "piece" is not, then obviously neither is the "whole". Jun 24, 2016 at 2:02
• So you want your function to be not differentiable on any! subinterval of your domain? For example, a function that is differentiable only at rational points? Is this what you are looking for? Jun 24, 2016 at 2:39
• @sranthrop: Not differentiable on any subinterval of an unbounded subinterval of the domain, yes. Jun 24, 2016 at 2:42
• Ok, so what about the Weierstrass-function: en.wikipedia.org/wiki/Weierstrass_function? Jun 24, 2016 at 4:40

So one may note that the only functions whose uniform continuity is really interesting to investigate, are the ones defined on an unbounded interval, being globally continuous, non-periodic and non-differentiable on an unbounded subinterval of their domain.

At risk of contradicting this assessment, not all subsets of the real line are intervals, and there are important examples and non-examples whose domain is not an interval.

• The cube root function $f(x) = \sqrt[3]{x}$ is uniformly continuous (but not Lipschitz) on the real line, unbounded, non-differentiable at the origin, and has unbounded derivative (near $0$).

• Let $n \geq 4$ be an integer. The function $$f(x) = \frac{\sin(x^{n})}{1 + x^{2}}$$ is real-analytic, bounded, and uniformly continuous (because it extends continuously over $\pm\infty$), but its derivative is easily checked to be unbounded as $|x| \to \infty$. That is, some claims in (3) are not OK.

• Monotonicity does not prevent examples of the preceding type. Let $(a_{k})_{k=1}^{\infty}$ be a summable sequence of positive real numbers, and let $g$ be the continuous function whose graph is the sum of triangular spikes of height $k$ and area $a_{k}$ centered at $k$. The function $$f(x) = \int_{0}^{x} g(t)\, dt$$ is bounded, continuously-differentiable (particularly, continuous), and monotone, hence uniformly continuous, but $\limsup f' = \infty$. This type of example can easily be made smooth (not merely $C^{1}$).

• Let $(a_{k})_{k=1}^{\infty}$ be a sequence of positive real numbers, and let $(x_{k})_{k=1}^{\infty}$ be an enumeration of the rationals. Let $$H(x) = \begin{cases} 0 & x < 0, \\ 1 & 0 \leq x, \end{cases}$$ be the Heaviside step function, and define $$g(x) = \sum_{x_{k} < x} a_{k} H(x - x_{k}),$$ with the sum extending over all $k$ with $x_{k} < x$. It's straightforward to check that $g$ is strictly monotone (hence integrable), has a jump discontinuity of size $a_{k}$ at $x_{k}$ for each $k$ and is continuous at every irrational number, and is bounded if and only if $(a_{k})$ is summable. Defining $$f(x) = \int_{0}^{x} g(t)\, dt$$ defines a continuous function that is non-differentiable at every rational, differentiable at every irrational, and is uniformly continuous if and only if $(a_{k})$ is summable.

• Incidentally, every real-valued function defined on the integers (or on any set having no real limit points) is uniformly continuous.

Conversely,

• The signum function $\operatorname{sgn}(x) = \dfrac{x}{|x|}$, $x \neq 0$, is locally constant (derivative identically zero) but (because it has no continuous extension to $0$) not uniformly continuous on its domain. This is closely related to a branch of polar angle function $\theta$ defined on a slit plane, which is differentiable on a connected set (and can be arranged to have bounded gradient), but not uniformly continuous.

• If $n \geq 2$ is an integer, then $f(x) = \sin(x^{n})$ is real-analytic and bounded, but of course not uniformly continuous. (This may contradict the claim in the comments that "...if all the "pieces" are uniformly continuous, then the "whole" can be shown to be as well simply by splitting the nasty subinterval in the nice smaller subintervals and proceed as in the last part of (3)." Specifically, if you split the real line into intervals of non-negativity and non-positivity, then $f$ is uniformly continuous on each subinterval. You need "uniform uniform continuity" to make the proposed argument work.)

• The combination of (2) and the first part of (3) settles $x\mapsto \dfrac{\sin x^n}{1+x^2}, \text{with} n\in\mathbb{N}\setminus\{0,1,2,3\}$ as well. Do note I said "Otherwise, let $f$ be differentiable. ...". The subsequent function is handled by the first part of (3) alone. A counterexample to (3) would be a function bounded but with no limit at $\infty$, with a divergent derivative at $\infty$, yet uniformly continuous. I really like the second integral function. Jun 26, 2016 at 12:03
• Yeah, I realized my claim was wrong. My last concern is about your counterexample to (3): since I suspect there must exist more "masked" counterexamples (e.g. not linear combinations nor compositions of finitely many u.c. functions), why is it that the derivative being asymptotically unbounded does not prevent $f$ from being u.c. ? Is there an extra constraint? I must be misusing MVT in my "proof", aided by the fact that several high-rep users seem to have made the same mistake! What is the mistake in the "proof" (which is really just applying MVT and considering $(x,y)$ with $x,y\to\infty$)? Jun 26, 2016 at 15:57
• In order for the MVT to be problematic, "$|f'|$ must be large on intervals whose lengths are uniformly bounded away from $0$". :) One way to avoid/control this precisely is to choose "tall spikes of small area" in the derivative. Jun 26, 2016 at 16:56
• That use of "uniformly" is really just for emphasis. :) Strictly, "intervals whose lengths are bounded away from $0$" conveys the same meaning: There is an $a > 0$ such that for every $M > 0$, there exists an interval $I$ of length at least $a$ such that $f' > M$ (or $f' < -M$) on $I$. (In this case, u.c. fails by your MVT argument because for every $\delta > 0$ and every $M > 0$, there exist $x$, $y$ such that $|x - y| < \delta$ but $|f(x) - f(y)| \geq M\delta$.) Jun 26, 2016 at 21:13
• Yeah, it finally appears obvious that if $\delta$ vanishes as $M$ gets bigger then $\lvert M\rvert \delta$ might vanish too, and $\lvert M\rvert \delta$ being bounded away from $0$ is the key of the counter-argument. Thanks again! Apr 21, 2017 at 19:43

Just an idea already mentioned in my comment:

Consider a Weierstraß-function \begin{align*} \omega(x):=\sum_{k=0}^\infty\frac{1}{2^k}\sin(2^kx). \end{align*} Then it is well-known that $\omega$ is uniformly continuous but nowhere differentiable in $\mathbb R$. However, $\omega$ is $2\pi$-periodic.

Consider $f(x):=x\omega(x)$. Then $f$ is still continuous, but not periodic and nowhere differentiable in $\mathbb R\backslash\{0\}$, since for $x\neq x_0\neq0$ we have \begin{align*} \frac{f(x)-f(x_0)}{x-x_0}=x\cdot\frac{\omega(x)-\omega(x_0)}{x-x_0}+\omega(x_0). \end{align*} Moreover, for $x>y$ with $\omega(x)>\omega(y)$ we have \begin{align*} f(x+2\pi k)-f(y+2\pi k)=(x+2\pi k)\omega(x)-(y+2\pi k)\omega(y)>(y+2\pi k)(\omega(x)-\omega(y)) \end{align*} for $k\in\mathbb N$, showing that $f$ is not uniformly continuous.

If you define $g(x):=\omega(x)/n$ for $x\in[2\pi n,2\pi(n+1)),n\in\mathbb Z$, then $g$ is uniformly continuous, but (shown similar) nowhere differentiable and not periodic.

• +1, thank you. I'll wait to see if someone else shows up. Jun 24, 2016 at 9:45