Can every continuous function $f(x)$ from $\mathbb{R}\to \mathbb{R}$ be continuously "transformed" into a differentiable function?

More precisely is there always a continuous (non constant) $g(x)$ such that $g(f(x))$ is differentiable?

  • This seems to hold for simple functions, for instance the function $f(x)=|x|$ can be transformed into a differentiable function by the function $g(x)=x^2$.
  • If $g(x)$ is additionally required to be increasing everywhere and differentiable then the answer seems to be no by the inverse function theorem, because of the existence of continuous nowhere differentiable functions.
  • 1
    $\begingroup$ Relevant: On transformations of derivatives (1975) AND Differentiability through change of variables (1976) AND Creating differentiability and destroying derivatives (1978), all 3 by Andrew M. Bruckner. $\endgroup$ Jun 26, 2021 at 15:38
  • $\begingroup$ @DaveL.Renfro Sadly they only talk about homeomorphisms , I also looked in Bruckners derivatives book but could find anything there $\endgroup$ Jun 26, 2021 at 16:29
  • $\begingroup$ I don't really know anything about this topic, but I did know that Bruckner (and some others) had worked on it. I thought maybe the papers themselves, or their references, or items that cite these papers (those that you can find by googling) would have something useful for you, but I don't know enough to easily investigate this myself. $\endgroup$ Jun 26, 2021 at 17:50
  • $\begingroup$ Related: Can monsters of real analysis be tamed in this way? $\endgroup$ Jun 30, 2021 at 13:20
  • $\begingroup$ Introducing "new" concepts in mathematics such as "corners", "flat" and "infinite composition" is not without risk: unexpected side effects are lurking around the corner. If your only objective is to "make" everywhere continuous / nowhere differentiable functions everywhere differentiable, then a pretty standard technique like Gaussian blur (one-dimensional equivalent) certainly is preferrable. I have posted an answer along these lines, but clearly it is not appreciated, so I deleted it. $\endgroup$ Jul 1, 2021 at 15:08

3 Answers 3


Edit 1. I realized my proof has a mistake. Because I use the inverse function theorem on $g \circ f$, my answer only checks out if $g \circ f$ is required to be continuously differentiable.

Original answer. Here's a counterexample.

We say a function $f$ is locally injective at a point $x$ if there exists a small interval $(x - \delta, x + \delta)$ where $x$ is injective. Suppose we have a function $f$ that is not locally injective at a point $x$. Also, suppose we have a function $g$ where the composition $g \circ f$ is differentiable at $x$. Note that because $f$ is not locally injective at $x$, $g \circ f$ cannot be locally injective by $x$. So by the inverse function theorem, its derivative $(g \circ f)'$ must necessarily vanish at $x$. This leads us to the following question:

Question. Can we find a function that is everywhere continuous, but nowhere locally injective?

If we can find such a function $f$, then any composition $g \circ f$ must be have an identically zero derivative. This means $g \circ f$ must be constant, implying $g$ is constant (at least in the range of $f$)!

We can achieve this with a function $f$ that is everywhere continuous, but nowhere differentiable. There are many such functions, the most famous being the “pathological” Weierstrass function. To prove $f$ is nowhere locally injective, suppose toward a contradiction that it is locally injective at a point $x$. Then there is in a small interval $I$ about $x$ where $f$ is injective and continuous, and hence monotone. By Lebesgue's monotone function theorem referenced in this post, $f$ must be differentiable almost everywhere in $I$. This is a contradiction because $f$ is nowhere differentiable.

Edit 2. Instead of examining local injectivity, we can maybe examine a slightly stronger condition. Let's say a function $f$ has a corner (not an actual term) at a point $x$ if for all $\delta > 0$, there exists $x_1, x_2 \in (x - \delta, x + \delta)$ such that $x_1 < x < x_2$ and $f(x_1) = f(x_2)$. The key here is that a “corner” requires the points breaking injectivity to lie on both sides of $x$.

We can show that if $f$ has a corner at $x$ and $g \circ f$ is differentiable at $x$, then $(g \circ f)'$ must vanish at $x$. For all $\delta > 0$, let $x_{1, \delta} < x < x_{2, \delta}$ be as in the definition of a corner. Taking the left-side points, we get $$ \tag{1} (g \circ f)'(x) = \lim_{\delta \to 0^+} \frac{(g \circ f)(x_{1, \delta}) - (g \circ f)(x)} {x_{1, \delta} - x}, $$ and taking the right-side points, we get $$ \tag{2} (g \circ f)'(x) = \lim_{\delta \to 0^+} \frac{(g \circ f)(x_{2, \delta}) - (g \circ f)(x)} {x_{2, \delta} - x}. $$ Note that the numerators of $(1)$ and $(2)$ are equal because $(g \circ f)(x_{1, \delta}) = (g \circ f)(x_{2, \delta})$. However, the denominators $x_{1, \delta} - x$ and $x_{2, \delta} - x$ have opposite signs, so we must have $(g \circ f)'(x) = 0$. Therefore, we can instead ask the question:

Question. Can we find a function that is everywhere continuous, but has a corner at every point in $\mathbb{R}$?

Because the Weierstrass function behaves like a fractal, this seems like it would be true (but maybe it only has corners densely packed in $\mathbb{R}$, in which continuous differentiability comes back to bite us). I'm not sure how to prove this though.

  • $\begingroup$ If $f(x_1) = f(x_2)$, then $g(f(x_1)) = g(f(x_2))$. So if $f$ is not locally injective at $x$, then we can find points $x_1, x_2$ arbitrarily close to $x$ where $f(x_1) = f(x_2)$. Then $g(f(x_1)) = g(f(x_2))$, which implies $g \circ f$ is not locally injective. $\endgroup$
    – Frank
    Jun 1, 2021 at 4:05
  • $\begingroup$ Yeah, that was my intuition. $\endgroup$
    – Frank
    Jun 1, 2021 at 18:02
  • $\begingroup$ If you're referring to equation (1), note that $\delta$ is always positive. $\endgroup$
    – Frank
    Jun 2, 2021 at 6:26
  • $\begingroup$ Inspired by this answer, I found a different stronger form of "nowhere locally injective" which let me construct an explicit counterexample. $\endgroup$ Jun 27, 2021 at 23:59

Inspired by Frank's notion of "corner", let's define

  • The function $f$ has a "flat" at $x$ iff for every $\delta>0$ there is an $x_1$ with $0<|x-x_1|<\delta$ such that $f(x_1)=f(x)$. (In other words, $x$ is a limit point of the fiber of $f$ it's a member of).

One easily proves:

  1. If $f$ is differentiable at $x$ and has a flat at $x$, then $f'(x)=0$.

  2. The points where $f$ has flats depend only on the set of fibers of $f$ -- or, in other words, on the equivalence relation $x\sim_f y \Leftrightarrow f(x)=f(y)$.

  3. If $f$ has a flat at $x$ and $g$ is an arbitrary function, then $g\circ f$ also has a flat at $x$.

I will construct a continuous surjection $f:\mathbb R\to \mathbb R$ where every $x$ is flat (that is, in more dignified terms, a function whose fibers are all perfect sets). This property guarantees that $g\circ f$ can only be differentiable if it is constant.

First, let $w:[0,1]\to[0,1]$ be a zig-zag function that goes from $0$ up to $1$, then down to $0$ and back up to $1$:

$$ w(x) = \begin{cases} 3x & 0 \le x \le 1/3 \\ 2 - 3x & 1/3 \le x \le 2/3 \\ 3x - 2 & 2/3 \le x \le 1 \end{cases} $$

Stack an infinite sequence of $w$s to get $u:\mathbb R\to \mathbb R$: $$ u(x) = \lfloor x\rfloor + w\bigl(x-\lfloor x\rfloor\bigr) $$ We note that $u$ is continuous and $|u(x)-x|<1$ everywhere.

Now for each $n\ge 0$, let $$ h_n(x) = \frac{u(2^n x)}{2^n} $$ This looks like $u$, except that we have "zoomed out" by a factor of $2^n$ so we have more and smaller wiggles around $x=y$. In particular, $|h_n(x)-x|\le 2^{-n}$.

Now form the infinite composition of all the $h_n$'s: $$ f = \lim_{n\to\infty} h_n \circ h_{n-1} \circ \cdots \circ h_1 \circ h_0 $$ or, written in more detail: $$ f_0(x) = x \qquad\qquad f_{n+1}(x) = h_n(f_n(x)) \qquad\qquad f(x) = \lim_{n\to\infty} f_n(x) $$ The limit exists pointwise because the bound on the wiggles on each $h_n$ makes the sequence Cauchy -- and this argument actually bounds the difference uniformly. So $f$ is continuous, being a uniform limit of continuous functions.

To see that $f$ has flats everywhere, it is convenient to define $$ k_n(x) = 2^n f_n(x) $$ We then have the recurrence $$ k_0(x) = x \qquad\qquad k_n(x) = 2u(k_{n-1}(x)) $$ In other words, we're just iterating $2u$. We don't need to worry about taking the limit anymore, because the fibers of the $k_n$s (and therefore also of $f_n$) will tell us enough to conclude that $f$ has flats everywhere.

Note that $k_n$ is piecewise linear, with each linear piece having slope $\pm 6^n$, and it changes direction only at points where $k_n(x)$ is an (even) integer.

Now suppose we're given $x$ and we're looking for a $x_1$ within $\delta=6^{-n}$ of $x$ where $f(x_1)=f(x)$. We fast-forward to $k_n$ and find that $x$ lies in a closed interval $[y,y+6^{-n}]$ where $k_n(x)$ either ascends linearly from an integer to the next or descends from an integer to the previous (namely, $y=6^{-n}\lfloor 6^n x\rfloor$ will work). This means that $k_{n+1}$ restricted to this interval attains each value in its image at least twice. So we can find an $x_1\ne x$ in the interval such that $k_{n+1}(x_1) = k_{n+1}(x)$ and therefore also $f(x_1)=f(x)$, as required.

  • $\begingroup$ (I'm fairly sure one could also set $u(x) = x + \alpha \sin(2\pi x)$, with $\alpha\approx 0.73264413$ chosen so the local minimum near $x=0.715$ is exactly $0$. That would make the $f_n$s (but not $f$, of course) nice and smooth -- but it would also make it more complicated to be sure that there's always a $k_n$ whose wiggles are narrow enough to fit into a $\delta$.) $\endgroup$ Jun 28, 2021 at 1:49
  • 1
    $\begingroup$ What was the motivation for taking the infinite composition ? $\endgroup$ Jun 28, 2021 at 8:32
  • $\begingroup$ @PaxDaga: Umm, that I can prove it works? In particular, it's a way to add more wiggles that's guaranteeed to preserve already-established $f(x_1)=f(x_2)$ relations, which would'n't be the case if I added new wiggles (like in the Weierstrass function). $\endgroup$ Jun 28, 2021 at 10:58
  • $\begingroup$ With hindsight, you could say that I'm trying to give the function a property that says "no matter which $g$ we compose on the left, such-and-such will be true". Thus when my construction takes multiple steps, combining the steps by composition instead of addition naturally means that later steps will not ruin the parts of the property I've already achieved. $\endgroup$ Jun 28, 2021 at 11:09
  • 1
    $\begingroup$ @PaxDaga: Do you mean a continuous function $\mathbb R\to\mathbb R$ such that $f(q)=0$ for every $q\in\mathbb Q$? The only such function is the constant zero function, not much of a counterexample :-) $\endgroup$ Jul 6, 2021 at 17:11

Gillis, Note on a conjecture of Erdos, Quart. J. of Math.,Oxford 10, (1939),151-154, has an example of a continuous function $f$, all of whose level sets are Cantor sets. Unless $g$ is a constant function, it seems $g \circ f$ won't be differentiable. (Gillis made other claims that were false, but his function does have every level set being a Cantor set).

Foran also has an example, but I don't think he published it. He constructs its graph as the intersection of a nested sequence of rectangles in the unit square.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .