Many function classes are stable under the elementary algebraic operations: if two functions \(f\) and \(g\) belong to some class, the same is true for the sum \(f+g\), the difference \(f-g\), the product \(fg\), and the quotient \(f/g\) (if defined). Some simple function classes are also stable under compositions; for example, it is taught in every first year calculus course that the composition \(g\circ f\) of two continuous [resp. Lipschitz continuous resp. differentiable] functions \(f\) and \(g\) is also continuous [resp. Lipschitz continuous resp. differentiable], where the derivative of \(g\circ f\) in the latter case may be calculated by the chain rule.

In many cases, however, the situation is more complicated for the composition: here one usually has to impose an additional condition on one of the functions \(f\) or \(g\) to guarantee that a certain property of them carries over to \(g\circ f\). The aim of this survey is to provide a series of counterexamples which illustrate this situation; such counterexamples may be useful for enriching your calculus course and for preventing your students from jumping too fast to wrong conclusions.

We note en passant that sometimes quite the opposite may be true: compositions are well-behaved, but algebraic operations are not. For instance, it is completely trivial that the composition of two Darboux functions \(f,g:\mathbb{R}\to\mathbb{R}\) (i.e., functions with the intermediate value property) is again a Darboux function. On the other hand, the two oscillation functions

$$f(x):=\left\{\begin{array}[]{lll}\sin\dfrac{1}{x}&\text{for}&x\neq 0,\\ 1&\text{for}&x=0,\end{array}\right.\qquad g(x):=\left\{\begin{array}[]{lll}-\sin\dfrac{1}{x}&\text{for}&x\neq 0,\\ 0&\text{for}&x=0,\end{array}\right.$$

are both Darboux functions, but their sum is the characteristic function \(f+g=\chi_{\{0\}}\) which fails to have the intermediate property. A similar phenomenon is true for the Luzin property:Footnote 1 it is again completely trivial that the composition of two functions \(f,g:\mathbb{R}\to\mathbb{R}\) with the Luzin property has again the Luzin property; on the other hand, in [11, Exercise 21.G] one can find two functions \(f,g:[0,1]\to\mathbb{R}\) with the Luzin property whose sum \(f+g\) fails to have the Luzin property.

Some of the examples presented in the sequel are “folklore”, some are our own spontaneous invention. The reader should not be deceived by the simplicity of certain questions: the answer is sometimes pretty surprising.

1 Continuity and variation

Throughout this paper, we consider functions \(f\) which map some interval \(I\) into some interval \(J\), and compose them with functions \(g:J\to\mathbb{R}\). We start with functions of bounded variation, i.e., functions \(f:[a,b]\to\mathbb{R}\) whose total Jordan variation

$$\text{Var}(f;[a,b]):=\sup_{P}\,\sum_{j=1}^{m}|f(t_{j})-f(t_{j-1})|$$

is finite, where the supremum is taken over all partitions \(P=\{t_{0},t_{1},\ldots,t_{m}\}\) (with variable \(m\)) of the interval \([a,b]\). Our first example shows that the composition of two functions of bounded variation need not have bounded variation.

Example 1

Let \(f:[0,1]\to[0,1]\) be the oscillation function defined by

$$f(x):=\left\{\begin{array}[]{lll}x^{2}\sin^{2}\displaystyle\frac{1}{x}&\text{for}&0<x\leq 1,\\ 0&\text{for}&x=0.\end{array}\right.$$

A straightforward calculation shows that \(f\) is differentiable on \([0,1]\) with

$$f^{\prime}(x)=\left\{\begin{array}[]{lll}2x\sin^{2}\displaystyle\frac{1}{x}-2\sin\frac{1}{x}\cos\frac{1}{x}&\text{for}&0<t\leq 1,\\ 0&\text{for}&x=0.\end{array}\right.$$

Consequently, \(|f^{\prime}(x)|\leq 4\) which shows that \(f^{\prime}\) is boundedFootnote 2 on \([0,1]\). This implies that \(\text{ Var}(f;[0,1])\leq 4\), so \(f\) has bounded variation.

Moreover, the function \(g:[0,1]\to\mathbb{R}\) defined by \(g(y):=\sqrt{y}\), being monotone, also has bounded variation. On the other hand, the total variation of the composition \(g\circ f\) is infinite.Footnote 3\(\Box\)

Example 1 shows that the composition of a function \(f\) of bounded variation and a Hölder continuous function \(g\) with Hölder exponent \(\alpha=1/2\) may have unbounded variation. The question arises whether or not we can give such a functions \(g\) also with arbitrary preassigned Hölder exponent \(\alpha\in(0,1)\). This is in fact possible, as the following example shows.

Example 2

Fix \(\alpha\in(0,1)\), and let \(g(u):=u^{\alpha}\). It is clear that \(g\) is Hölder continuous on \([0,1]\) with maximal Hölder exponent \(\alpha\). We define \(f:[0,1]\to[0,1]\) by taking, for \(n\in\mathbb{N}\),

$$f(x):=\left\{\begin{array}[]{ll}0&\text{for }x=0\text{ or }x=\dfrac{1}{2n-1},\\ \dfrac{1}{n^{1/\alpha}}&\text{for }x=\dfrac{1}{2n},\\ \text{linear}&\text{otherwise}.\end{array}\right.$$

Then

$$\text{Var}(f;[0,1])=2\sum_{n=1}^{\infty}\frac{1}{n^{1/\alpha}}<\infty,$$

since \(\alpha<1\). Consequently, \(f\) has finite variation on \([0,1]\). On the other hand,

$$g\left(f\left(\frac{1}{2n}\right)\right)-g\left(f\left(\frac{1}{2n-1}\right)\right)=\frac{1}{n},$$

which implies that the total variation of \(g\circ f\) is infinite. \(\Box\)

A very important class which is related both to continuity and bounded variation is the set of absolutely continuous functions. This set is a linear space, and even an algebra. However, the composition of two absolutely continuous functions need not be absolutely continuous.

Example 3

Let \(f\) and \(g\) be the same functions as in Example 1. Having a bounded derivative, \(f\) is Lipschitz continuous on \([0,1]\), hence absolutely continuous. The function \(g\) is not Lipschitz continuous on \([0,1]\), but absolutely continuous. However, since \(g\circ f\) has unbounded variation, it cannot be absolutely continuous. \(\Box\)

Note that the composition of two absolutely continuous functions which is not absolutely continuous, as in Example 3, must have unbounded variation. In fact, the well-known Banach-Zaretskij theorem (see [2, p. 349] or [3, Theorem 4.6.2]) states that a function is absolutely continuous if and only if it has bounded variation, is continuous, and has the Luzin property. Since the last two properties are stable under compositions, the lack of absolute continuity can be only due to a lack of bounded variation.

In this connection, it is interesting to observe that \(g\circ f\) is indeed of bounded variation if \(f\) is increasing and \(g\) is of bounded variation, and \(g\circ f\) is absolutely continuous if \(f\) is increasing and both \(f\) and \(g\) are absolutely continuous. So it is not accidental that the inner function \(f\) in Example 3 is heavily oscillating.

Monotone functions, and so also functions of bounded variation, by Jordan’s decomposition theorem [4, Corollary 13.6], are not “too discontinuous”, inasmuch as they can have only removable discontinuities or discontinuities of first kind (jumps). Functions with this property are called regular. The next example shows that the composition of two regular functions need not be regular.

Example 4

Define an oscillation function \(f:[-1,1]\to[-1,1]\) by

$$f(x):=\left\{\begin{array}[]{lll}x\sin\dfrac{1}{x}&\text{for}&0<|x|\leq 1,\\ 0&\text{for}&x=0,\end{array}\right.$$

and let \(g:[-1,1]\to\mathbb{R}\) be the restriction of the signum function to \([-1,1]\), i.e.,

$$g(y):=\left\{\begin{array}[]{rll}-1&\text{for}&-1\leq y<0,\\ 0&\text{for}&y=0,\\ 1&\text{for}&0<y\leq 1.\end{array}\right.$$

Then \(f\) is regular (even continuous), and \(g\) is also regular (even monotone). On the other hand, \(g\circ f\), having a discontinuity of second kind at 0, is not regular. \(\Box\)

In view of Example 3 the question arises if, given two absolutely continuous \(f\) and \(g\), we can impose better properties on one of these functions to make \(g\circ f\) absolutely continuous. It is very easy to see that a possible such conditionFootnote 4 is Lipschitz continuity of the outer function \(g\). On the other hand, Example 3 shows that it does not help to require Lipschitz continuity of the inner function \(f\). The same example shows that we cannot weaken Lipschitz continuity of \(g\) to Hölder continuity to ensure the absolute continuity of \(g\circ f\).

A more general class than continuous functions is that of Baire class one functions, which means pointwise limits of sequences of continuous functions. This class contains not only all continuous functions, but also all functions of bounded variation, and even all regular functions. An important result [11, Theorem 11.4] states that the points of discontinuity of a Baire class one function \(f:\mathbb{R}\to\mathbb{R}\) form a meager \(F_{\sigma}\) set. Consequently, the points of continuity of such a function form a dense set. This implies that the Dirichlet function \(f=\chi_{\mathbb{Q}}\) is not Baire class one.Footnote 5

Sums, products, and uniform limits of Baire class one functions are again Baire class one. However, taking compositions one may leave this class.

Example 5

Let \(f:[0,1]\to[0,1]\) be the Riemann function defined byFootnote 6

$$f(x):=\left\{\begin{array}[]{rll}\dfrac{1}{q}&\text{for}&x=\dfrac{p}{q}\in[0,1]\cap\mathbb{Q},\\ 0&\text{for}&x\in[0,1]\setminus\mathbb{Q}.\end{array}\right.$$

The function \(f\) is Baire class one, and it is continuous precisely at each irrational point. The characteristic function \(g:=\chi_{(0,1]}\), being monotone, is also Baire class one. However, \(g\circ f\) is the Dirichlet function which is not Baire class one. \(\Box\)

It is easy to see that \(g\circ f\) is Baire class one if \(f\) is Baire class one and \(g\) is continuous, or vice versa.Footnote 7

Now we pass to semicontinuous functions: \(f:\mathbb{R}\to\mathbb{R}\) is upper semicontinuous at \(x_{0}\in\mathbb{R}\) if

$$f(x_{0})\geq\limsup_{x\to x_{0}}\,f(x),$$

and lower semicontinuous at \(x_{0}\in\mathbb{R}\) if

$$f(x_{0})\leq\liminf_{x\to x_{0}}\,f(x).$$

It is almost trivial to prove that the upper resp. lower semicontinuity of \(g\) carries over to \(g\circ f\) provided that the inner function \(f\) is continuous. Interestingly, in the reverse order this is false.

Example 6

The oscillation function \(f:[0,1]\to[-1,2]\) defined by

$$f(x):=\left\{\begin{array}[]{lll}\sin\displaystyle\frac{1}{x}&\text{for}&x\neq 0,\\ 2&\text{for}&x=0\end{array}\right.$$

is upper semicontinuous. Moreover, the function \(g\) defined by \(g(y):=(3-y)(y+1)\) is clearly continuous on \(\mathbb{R}\). However, for the function \(g\circ f\) we have

$$\limsup_{x\to 0}\,g(f(x))=4> 3=g(f(0)),\quad\liminf_{x\to 0}\,g(f(x))=0<3=g(f(0)).$$

Consequently, \(g\circ f\) is neither upper nor lower semicontinuous. \(\Box\)

In view of Example 6 we mention that \(g\circ f\) is upper semicontinuous if \(f\) is upper semicontinuous and \(g\) is upper semicontinuous and increasing, or \(f\) is lower semicontinuous and \(g\) is upper semicontinuous and decreasing. Similarly, \(g\circ f\) is lower semicontinuous if \(f\) is lower semicontinuous and \(g\) is lower semicontinuous and increasing, or \(f\) is upper semicontinuous and \(g\) is lower semicontinuous and decreasing. Thus, it is not accidental that the function \(g\) in Example 6 is not globally monotone, but only piecewise monotone on \((-\infty,1]\) and \([1,\infty)\).

Splitting the limit for \(x\to x_{0}\) into the unilateral limits \(x\to x_{0}-\) and \(x\to x_{0}+\) in the definition of derivatives, one may define one-sided diferentiability. Recall that the left resp. right derivative of \(f\) at \(x_{0}\in\mathbb{R}\) is defined by

$$\lim_{x\to x_{0}-}\,\frac{f(x)-f(x_{0})}{x-x_{0}},\qquad\lim_{x\to x_{0}+}\,\frac{f(x)-f(x_{0})}{x-x_{0}}.$$

It is worthwhile mentioning that one-sided differentiability does not imply continuity (unless both the left and right derivative exist). For example, the characteristic function \(\chi_{(0,1)}\) is only left differentiable at 0, and only right differentiable at 1. Concerning compositions, here is an example.

Example 7

This example shows that the composition of two one-sided differentiable functions need not be one-sided differentiable. Let

$$f(x):=\left\{\begin{array}[]{lll}x^{2}\cos\dfrac{1}{|x|}&\text{for}&x\neq 0,\\ 0&\text{for}&x=0\end{array}\right.$$

and \(g(y):=2\chi_{[0,\infty)}(y)\). Then \(g\) is right differentiable at \(f(0)=0\), and \(f\) is even differentiable in the classical sense at \(x_{0}=0\). The sequence \((x_{n})_{n}\) defined by \(x_{n}=1/n\pi\) converges to 0 from above as \(n\to\infty\). However,

$$\frac{g\big(f(x_{n})\big)-g\big(f(0)\big)}{x_{n}-0}=n\pi\left(g\left(\frac{(-1)^{n}}{n^{2}\pi^{2}}\right)-1\right)=(-1)^{n}n\pi$$

diverges as \(n\to\infty\), and so \(g\circ f\) is not right differentiable at \(x_{0}=0\). Since \(f(x)=f(|x|)\), the composition \(g\circ f\) is not left differentiable at \(x_{0}=0\) either. \(\Box\)

Example 7 shows that \(g\circ f\) need not be one-sided differentiable if \(g\) is one-sided differentiable and \(f\) is even differentiable. The question arises what happens if we take \(f\) one-sided differentiable and \(g\) differentiable. Here we have a positive result: if \(f:\mathbb{R}\to\mathbb{R}\) is one-sided differentiable at \(x_{0}\), and \(g:\mathbb{R}\to\mathbb{R}\) is differentiable at \(f(x_{0})\), then \(g\circ f:\mathbb{R}\to\mathbb{R}\) is one-sided differentiable (in the same sense as \(f\)) at \(x_{0}\). We leave the proof to the reader.

2 Measurability and integrability

Now we pass to measurable and integrable functions. We start with the Riemann integral. Here we have Lebesgue’s well-known criterion for Riemann integrability: a real function is Riemann integrable on a compact interval if and only if it is bounded and its discontinuity set is a Lebesgue nullset. This implies, for example, that the Riemann function is integrable, but the Dirichlet function is not, and suggests the following

Example 8

This example shows that the composition of two Riemann integrable functions need not be Riemann integrable. Let \(f:[0,1]\to[0,1]\) be the Riemann function from Example 5, and \(g:[0,1]\to\mathbb{R}\) the characteristic function \(g(y):=\chi_{(0,1]}(y)\). Then \(g\circ f\) is the Dirichlet function which is not Riemann integrable. \(\Box\)

From Lebesgue’s criterion it follows that \(g\circ f\) is Riemann integrable if \(f\) is Riemann integrable and \(g\) is continuous. Example 8 shows that the latter condition is quite subtle: it suffices to make \(g\) discontinuous at just one point to destroy the integrability of \(g\circ f\).

Even more interesting is the fact that, as several times before, we cannot change the order in the composition.

Example 9

Denote by \({\cal C}^{\alpha}\subset[0,1]\) the Cantor set of measure \(\alpha> 0\) (see, e.g., [5, Example 8.4]), and define \(f:[0,1]\to[0,1]\) by

$$f(x):=\text{dist}(x,{\cal C}^{\alpha})=\inf\,\{|x-a|:a\in{\cal C}^{\alpha}\}.$$

Clearly, \(f\) is (even Lipschitz) continuous. Composing \(f\) with the Riemann integrable characteristic function \(g(y):=\chi_{\{{0}\}}(y)\), we end up with the characteristic function \(g\circ f=\chi_{{\cal C}^{\alpha}}\) of \({\cal C}^{\alpha}\) which is not Riemann integrable, because its discontinuity set \({\cal C}^{\alpha}\) has positive measure.Footnote 8\(\Box\)

Let us pass now to the Lebesgue measure and Lebesgue integral. Here we basically need only two counterexamples: one for two measurable functions whose composition is not measurable, and one for two integrable functions whose composition is not integrable. To this end, some preliminary remarks on nonmeasurable sets are in order.

Recall that the Cantor function \(\phi:[0,1]\to[0,1]\) associated to the ternary Cantor nullset \({\cal C}\) is surjective, continuous, and increasing, but not injective. The strict Cantor function \(\psi:[0,1]\to[0,1]\) given by \(\psi(x):=\frac{1}{2}(x+\phi(x))\) is even bijective, continuous, and strictly increasing (see, e.g., [5, Example 8.16]). Being monotone, the function \(\psi\) has bounded variation; however, it is not absolutely continuous, since it maps the nullset \({\cal C}\) into a set of positive measure, so it lacks the Luzin property.

Choose a nonmeasurable setFootnote 9\(E\subset\psi({\cal C})\). Since \(\psi\) is a homeomorphism, we deduce then that \(D:=\psi^{-1}(E)\subset{\cal C}\), and so \(D\) is a nullset.

Example 10

With \(\psi\), \(E\) and \(D\) as above, we define \(f,g:[0,1]\to[0,1]\) by \(f:=\psi^{-1}\) and \(g:=\chi_{D}\). Both functions are obviously Lebesgue measurable. On the other hand, since the composition \(g\circ f=\chi_{E}\) is the characteristic function of a nonmeasurable set, it cannot be measurable. \(\Box\)

Example 10 shows that we may lose measurability of the composition of two measurable functions even if the inner function is extremely well-behaved. Let us point out that the composition \(g\circ f\) of a measurable function \(f\) and a continuous functions \(g\) is always measurable, so also here we encounter the usual asymmetry.

Concerning Lebesgue integrability, finding a counterexample is quite easy.

Example 11

Define \(f:[0,1]\to\mathbb{R}\) by

$$f(x):=\left\{\begin{array}[]{lll}\displaystyle\frac{1}{\sqrt{x}}&\text{for}&0<x\leq 1,\\ 0&\text{for}&x=0.\end{array}\right.$$

It is well-known that \(f\) is Lebesgue integrable on \([0,1]\) with integral 2. However, composing \(f\) with the integrable function \(g(y):=y^{2}\) gives a nonintegrable function. \(\Box\)

Note that the function \(g\) is even analytic and monotone (on \((0,\infty)\)). This means that, in contrast to measurability, requiring stronger properties of the outer function does not help to ensure that a composition has the same integrability property as the inner function.

3 Further function classes

In this section we collect some more pathologies on compositions which seem worth mentioning. Recall that a real function \(f\) is globally continuous if and only ifFootnote 10 the preimage \(f^{-1}(M)\) is open [resp. closed] for each open [resp. closed] subset \(M\). A completely independent notion is openness or closedness of maps: a function \(f\) is called open [resp. closed] if the image \(f(M)\) is open [resp. closed] for each open [resp. closed] set \(M\). It is a completely trivial consequence of the definition that the composition of open [resp. closed] functions is again open [resp. closed]. However, one should not mix up these notions when dealing with two functions, as the following examples show.

Example 12

Let \(f,g:\mathbb{R}\to\mathbb{R}\) be defined by \(f(x):=x^{2}\) and \(g(y):=e^{-y}\). Then \(f\) is closed, but not open, while \(g\) is open, but not closed. However, the composition \(g\circ f:\mathbb{R}\to\mathbb{R}\) is neither closed nor open, since \((g\circ f)(\mathbb{R})=(0,1]\). \(\Box\)

Example 13

Likewise, let \(f,g:\mathbb{R}\to\mathbb{R}\) be defined by \(f(x):=\arctan x\) and \(g(y):=y^{2}\). Then \(f\) is open, but not closed, while \(g\) is closed, but not open. However, the composition \(g\circ f:\mathbb{R}\to\mathbb{R}\) is neither closed nor open, since \((g\circ f)(\mathbb{R})=[0,\pi^{2}/4)\). \(\Box\)

Another interesting class are functions \(f\) with primitive, i.e., \(f=F^{\prime}\) for some differentiable function \(F\). It is well known that every continuous function on an interval has a primitive, and every function with primitive has the intermediate value property. An example which shows that inclusions between these classes are strict is the parameter-dependent oscillation function \(f_{\tau}:[0,1]\to\mathbb{R}\) defined by

$$f_{\tau}(x):=\left\{\begin{array}[]{lll}\sin\dfrac{1}{x}&\text{for}&0<x\leq 1,\\ \tau&\text{for}&x=0.\end{array}\right.$$

So the function in Example 6 is \(f=f_{2}\). The function \(f_{\tau}\) is continuous for no value of \(\tau\), has the intermediate value property for \(-1\leq\tau\leq 1\), and has a primitive only for \(\tau=0\). In fact, a primitive of \(f=f_{0}\) is given in explicit form by

$$F(x):=\left\{\begin{array}[]{lll}x^{2}\cos\dfrac{1}{x}-2\displaystyle\int_{0}^{x}t\cos\frac{1}{t}\,dt&\text{for}&0<x\leq 1,\\ 0&\text{for}&x=0,\end{array}\right.$$

as may be verified by a straightforward calculation. We use this function to show that \(g\circ f\) need not have a primitive even if \(f\) has a primitive and \(g\) is very smooth.

Example 14

Let \(f=f_{0}:[0,1]\to[-1,1]\) be the function we just considered, and let \(g(y):=y^{2}\). We claim that \(g\circ f\) has no primitive. In fact, it is not hard to verify that \(h:=g\circ f\) has the primitive

$$H(x):=\frac{x}{2}+\frac{x^{2}}{4}\sin\frac{2}{x}-\frac{1}{2}\displaystyle\int_{0}^{x}t\sin\frac{2}{t}\,dt,$$

but only on the interval \((0,1]\). Calculating the derivative of \(H\) at zero directly yields

$$\lim_{x\to 0+}\,\frac{H(x)}{x}=\frac{1}{2}.$$

This means that \(H^{\prime}(x)\) has the “wrong value” in zero, so the square \(h=f^{2}\) has, in contrast to \(f\), no primitive. \(\Box\)

It is remarkable that this time also the reverse direction fails: if \(g\) has a primitive and \(f\) is even continuous and monotone, it may happen that \(g\circ f\) has no primitive. To illustrate this with a counterexample is harder than in Example 14; we briefly sketch the idea and refer the interested reader for a general discussion and more examples to Sect. 2.3 of the recent book [10].

Example 15

Let \(f:[0,1]\to[0,1]\) be the continuous increasing Cantor function which we already considered before Example 10. Being continuous, \(f\) has certainly a primitive. Putting \(h_{n}:=3^{n}\) and \(\delta_{n}:=12^{-n}\), we define a function \(g:[0,1]\to\mathbb{R}\) in such a way that the graph of \(g\) over every interval \(I_{n}:=[2^{-n}-\delta_{n},2^{-n}+\delta_{n}]\) is a triangle with vertices \((2^{-n}-\delta_{n},0)\), \((2^{-n}+\delta_{n},0)\), and \((2^{-n},h_{n})\). The function \(g\) can be given explicity on \(I_{n}\) by

$$g(y):=\left\{\begin{array}[]{lll}0&\text{for}&2^{-(n+1)}+\delta_{n+1}\leq y<2^{-n}-\delta_{n},\\ \displaystyle\frac{h_{n}}{\delta_{n}}\big(y-2^{-n}\big)+h_{n}&\text{for}&2^{-n}-\delta_{n}\leq y<2^{-n},\\ \displaystyle\frac{h_{n}}{\delta}\big(2^{-n}-y\big)+h_{n}&\text{for}&2^{-n}\leq y<2^{-n}+\delta_{n}.\end{array}\right.$$

Finally, we set \(g(y)=0\) for \(y=0\) or \(1/2+1/12\leq y\leq 1\). Since the function \(g\) is continuous on \([a,1]\) for every \(a\in(0,1)\), it has a primitive \(G\) on \((0,1]\) which may be calculated through the formula

$$G(y)=\frac{1}{3}-\int_{y}^{1}g(t)\,dt\qquad(0<y\leq 1).$$

However, being unbounded near zero, the function \(g\) is certainly not continuous on the whole interval \([0,1]\). Nevertheless, a somewhat cumbersome computation shows that we may extend \(G\) to a primitive of \(g\) on \([0,1]\) if we put \(G(0):=0\).

In this way we have constructed two functions \(f\) and \(g\) with primitives, where only \(f\) is continuous.Footnote 11 Let us now show that the composition \(h:=g\circ f:[0,1]\to\mathbb{R}\) does not have a primitive on \([0,1]\). In fact, suppose that \(H:[0,1]\to\mathbb{R}\) is differentiable with \(H^{\prime}(x)=h(x)\) for all \(x\in[0,1]\). Since \(h\) is continuous on \((0,1]\) we deduce that

$$H(1)-H(3^{-n})=\displaystyle\int_{3^{-n}}^{1}g\big(f(t)\big)\,dt\geq\sum_{k=1}^{n}\int_{3^{-k}}^{2\cdot 3^{-k}}g\big(f(t)\big)\,dt=\displaystyle\sum_{k=1}^{n}\frac{g\big(2^{-k}\big)}{3^{k}}=\sum_{k=1}^{n}\frac{h_{k}}{3^{k}}=n,$$

where we used the fact that \(f\) satisfies \(f([3^{-k},2\cdot 3^{-k}])=\{2^{-k}\}\). But the continuity of \(H\) on \([0,1]\) implies that the first term of this expression tends to \(H(1)-H(0)\) as \(n\to\infty\) which is impossible. \(\Box\)

4 Necessary conditions

Our main objective in the preceding sections may be formulated as follows: if we consider all functions \(f:[a,b]\to\mathbb{R}\) from a certain function class \(X[a,b]\), can you give a sufficient condition on a function \(g:\mathbb{R}\to\mathbb{R}\) such that also \(g\circ f\) belongs to \(X[a,b]\)? However, even when we have found a satisfactory answer to this question, it is not clear at all how far this sufficient condition was from being necessary. In this final section we therefore focus on finding conditions on \(g\) which are both necessary and sufficient. In other words, we want to have a precise condition on \(g\) which guarantees that \(g\circ f\in X[a,b]\) for all \(f\in X[a,b]\). To this end, we formally introduce the perturbation set

$${\cal P}(X):=\{g:g\circ f\in X\text{ for all }f\in X\}$$

which describes the maximal possible perturbation which does not take functions from \(X\) outside \(X\). For some classes \(X\) the description of \({\cal P}(X)\) is simple, for some classes complex, and for some others simply unknown. However, some preliminary considerations are helpful. For instance, if the identity \(f(x)=x\) belongs to \(X\), then clearly \({\cal P}(X)\subseteq X\). Conversely, if \(X\) is closed under compositions, the inclusion \({\cal P}(X)\supseteq X\) holds. As a consequence, we immediately deduce that

$${\cal P}(C)=C,\quad{\cal P}(Lip)=Lip,\quad{\cal P}(D)=D,$$

where \(C\) denotes the class of continuous functions, \(Lip\) the class of Lipschitz continuous functions, and \(D\) the class of functions with the intermediate value property. Denoting by \(BV\) the class of all functions of bounded variation, it was proved in [7] that \({\cal P}(BV)=Lip_{loc}\). With a similar reasoning one can show that \({\cal P}(AC)=Lip_{loc}\), where \(AC\) is the linear space of absolutely continuous functions. Consequently, whenever a function \(g:\mathbb{R}\to\mathbb{R}\) is not locally Lipschitz, we can find an absolutely continuous function \(f\) such that \(g\circ f\) is not of bounded variation. This explains why the function \(g\) in Example 1 is not Lipschitz continuous near zero, and why we cannot choose \(\alpha=1\) in Example 2.

Denoting by \(\Delta\) the set of all functions with primitive, the problem of characterizing \({\cal P}(\Delta)\) was open for a long time. It is clear that every affine function \(g(y)=\alpha y+\beta\) with fixed \(\alpha,\beta\in\mathbb{R}\) belongs to \({\cal P}(\Delta)\): if \(F\) is a primitive of \(f\), the function \(H(x):=\alpha F(x)+\beta x\) is a primitive of \(h=g\circ f\). The solution of this problem is rather surprising [1]: the set \({\cal P}(\Delta)\) contains only affine functions! Consequently, whenever a function \(g:\mathbb{R}\to\mathbb{R}\) is not affine, we can find a function \(f\) with a primitive such that \(g\circ f\) does not have a primitive. This explains in turn why even such a well-behaved analytic function like \(g(y)=y^{2}\) in Example 14 may destroy the existence of primitives.

To conclude, we remark that it is also interesting to slightly change our point of view and consider the following question: suppose \(f:I\to J\) is continuous and onto, and \(g\circ f:I\to\mathbb{R}\) has a property we are interested in; for which properties can we infer that \(g:J\to\mathbb{R}\) has then the same property? In the paper [9] the authors study this problem for continuous functions and Darboux functions. It is well-known that such properties may be recognized, at least in part, by looking at the graph

$$\Gamma(f):=\{(x,f(x)):x\in I\}$$

of \(f\). Thus, \(f\) is continuous if and only if \(\Gamma(f)\) is pathwise connected,Footnote 12 and \(f\) is a Darboux function if \(\Gamma(f)\) is connected. The converse of the latter assertion is not true, since one may construct rather counter-intuitive Darboux functions \(f:\mathbb{R}\to\mathbb{R}\) with disconnected graph. Now, in [8] and [9] the following four interesting results, among others, are stated, proved, and discussed:

  • If \(I\) and \(J\) are compact, \(f:I\to J\) is continuous and onto,Footnote 13 and \(g\circ f:I\to\mathbb{R}\) is continuous, then also \(g\) is continuous.

  • If \(f:I\to J\) is continuous and onto, and \(g\circ f:I\to\mathbb{R}\) has a connected graph, then also \(g\) has a connected graph.

  • If \(f:I\to J\) is continuous and onto, and \(g\circ f:I\to\mathbb{R}\) is a Darboux function, then also \(g\) is a Darboux function.

  • If \(f:I\to J\) is a Darboux function and onto, \(g:J\to\mathbb{R}\) is a Darboux function, and \(g\circ f:I\to\mathbb{R}\) is continuous, then also \(g\) is continuous.

The proof of the first assertion is an immediate consequence of the closed graph theorem, while the proof of the second assertion follows from the equality

$$\Phi(\Gamma(g\circ f))=\{(f(x),g(f(x))):x\in I\}=\{(y,g(y)):y\in J\}=\Gamma(g),$$

where \(\Phi:I\times\mathbb{R}\to J\times\mathbb{R}\) is defined by \(\Phi(x,y):=(f(x),y)\), and we again used the surjectivity of \(f\) for the second equality sign. The third and fourth assertions, however, require more sophisticated arguments.

We point out that also in the last of the above four statements we have a certain asymmetry in the following sense: if \(f:I\to J\) is a Darboux function, and both \(g:J\to\mathbb{R}\) and \(g\circ f:I\to\mathbb{R}\) are continuous, we cannot deduce that also \(f\) is continuous. A corresponding counterexample may be found in [8].

Finally, we remark that compositions of functions with connected graph are difficult to handle. Here we mention two positive results: first, if \(f:I\to J\) is continuous, and \(g:J\to\mathbb{R}\) has a connected graph, then also \(g\circ f:I\to\mathbb{R}\) has a connected graph [6]; second, if \(f:I\to J\) has a connected graph, and \(g:J\to\mathbb{R}\) is continuous, then also \(g\circ f:I\to\mathbb{R}\) has a connected graph [9]. In the paper [9] the authors also construct a function \(f\) on the “comb space” with infinitely many teeth

$$X:=([0,1]\times\{0\})\cup\{(0,1)\}\cup\bigcup_{n=1}^{\infty}(\{1/n\}\times[0,1])$$

and a connected graph with a squeezed shifted oscillation function \(g:[0,1]\to\mathbb{R}\) with connected graph such that the composition \(g\circ f:X\to\mathbb{R}\) does not have a connected graph. Of course, it would be nice to have an example where not only \(g\), but also \(f\) is defined on an interval. Unfortunately, we have been unable to find such an example.

The described problem of drawing conclusions from a property of a composition \(g\circ f\) to properties of the factors \(f\) and \(g\) is of interest even for much simpler classes of maps. For example, we mention some results for \(f,g:\mathbb{R}\to\mathbb{R}\) which are almost trivial, but even hold for maps between arbitrary topological spaces:

  • If \(g\circ f\) is open, and \(g\) is injective and continuous, then also \(f\) is open.

  • If \(g\circ f\) is open, and \(f\) is surjective and continuous, then also \(g\) is open.

The same is true with “open” replaced with “closed”. One may easily show that these assertions are not true without the injectivity requirement for \(g\) or the surjectivity requirement for \(f\). This is our last example.

Example 16

Define \(f:\mathbb{R}\to\mathbb{R}\) and \(g:\mathbb{R}\to\mathbb{R}\) by

$$f(x):=\left\{\begin{array}[]{lll}x-1&\text{for}&x<0,\\ 0&\text{for}&x=0,\\ x+1&\text{for}&x> 0,\end{array}\right.\qquad g(y):=\left\{\begin{array}[]{lll}y+1&\text{for}&y<-1,\\ 0&\text{for}&-1\leq y\leq 1\\ y-1&\text{for}&y> 1.\end{array}\right.$$

Then \(g\) is continuous and \((g\circ f)(x)=x\) is open (and even a homeomorphism on \(\mathbb{R}\)). However, \(g\) is not injective, and \(f\) is not open.

Define \(f:\mathbb{R}\to\mathbb{R}\) and \(g:\mathbb{R}\to\mathbb{R}\) by \(f(x):=e^{x}\) and \(g(y):=y^{2}\). Then \(f\) is continuous and \((g\circ f)(x)=e^{2x}\) is open (and even a homeomorphism between \(\mathbb{R}\) and \((0,\infty)\)). However, \(f\) is not surjective, and \(g\) is not open. \(\Box\)