Counterexamples on compositions

We give a collection of 16 examples which show that compositions g∘f\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$g\circ f$$\end{document} of well-behaved functions f\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$f$$\end{document} and g\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$g$$\end{document} can be badly behaved. Remarkably, in 10 of the 16 examples it suffices to take as outer function g\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$g$$\end{document} simply a power-type or characteristic function. Such a collection of examples may serve as a source of exercises for a calculus course.

Lipschitz continuous resp. differentiable], where the derivative of g ı 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 ı 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 W R ! R A similar phenomenon is true for the Luzin property: 1 it is again completely trivial that the composition of two functions f; g W R ! 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 W OE0,1 ! R with the Luzin property whose sum f C 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.

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 W J ! R. We start with functions of bounded variation, i.e., functions f W OEa; b ! R whose total Jordan variation jf .t j / f .t j 1 /j is finite, where the supremum is taken over all partitions P D ft 0 ; t 1 ; :::; t m g (with variable m) of the interval OEa; b. Our first example shows that the composition of two functions of bounded variation need not have bounded variation.
Example 1 Let f W OE0,1 ! OE0,1 be the oscillation function defined by A straightforward calculation shows that f is differentiable on OE0,1 with Consequently, jf 0 .x/j Ä 4 which shows that f 0 is bounded 2 on OE0,1. This implies that Var.f I OE0,1/ Ä 4, so f has bounded variation.
Moreover, the function g W OE0,1 ! R defined by g.y/ WD p y, being monotone, also has bounded variation. On the other hand, the total variation of the composition g ı f is infinite. 3 Example 1 shows that the composition of a function f of bounded variation and a Hölder continuous function g with Hölder exponent˛D 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˛2 .0,1/. This is in fact possible, as the following example shows.

Example 2
Fix˛2 .0,1/, and let g.u/ WD u˛. It is clear that g is Hölder continuous on OE0,1 with maximal Hölder exponent˛. We define f W OE0,1 ! OE0,1 by taking, for n 2 N, linear otherwise: Then Var.f I OE0,1/ D 2 1 X nD1 1 n 1=˛< 1; since˛< 1. Consequently, f has finite variation on OE0,1. On the other hand, which implies that the total variation of g ı f is infinite. 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 OE0,1, hence absolutely continuous. The function g is not Lipschitz continuous on OE0,1, but absolutely continuous. However, since g ı f has unbounded variation, it cannot be absolutely continuous.
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 ı f is indeed of bounded variation if f is increasing and g is of bounded variation, and g ı 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. 1 for 1 Ä y < 0; 0 for y D 0; 1 for 0 < y Ä 1.
Then f is regular (even continuous), and g is also regular (even monotone). On the other hand, g ı f , having a discontinuity of second kind at 0, is not regular.
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 ı f absolutely continuous. It is very easy to see that a possible such condition 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 ı 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 W R ! R form a meager F set. Consequently, the points of continuity of such a function form a dense set. This implies that the Dirichlet function f D Q is not Baire class one. 5 Sums, products, and uniform limits of Baire class one functions are again Baire class one. However, taking compositions one may leave this class.
The function f is Baire class one, and it is continuous precisely at each irrational point. The characteristic function g WD .0,1 , being monotone, is also Baire class one. However, g ı f is the Dirichlet function which is not Baire class one.
It is easy to see that g ı f is Baire class one if f is Baire class one and g is continuous, or vice versa. 7 Now we pass to semicontinuous functions: and lower semicontinuous at It is almost trivial to prove that the upper resp. lower semicontinuity of g carries over to g ı f provided that the inner function f is continuous. Interestingly, in the reverse order this is false.

Example 6
The oscillation function f W OE0,1 ! OE 1,2 defined by This may also easily be proved directly. 6 Here we assume, of course, that p and q are coprime, i.e., have no common divisors d > 1. 7 More generally, one may define higher order Baire classes, considering continuous functions as Baire class zero, and show that g ı f is Baire class m C n if f is Baire class m and g is Baire class n. For example, the Dirichlet function is Baire class 2.
is upper semicontinuous. Moreover, the function g defined by g.y/ WD .3 y/.yC1/ is clearly continuous on R. However, for the function g ı f we have lim sup Consequently, g ı f is neither upper nor lower semicontinuous.
In view of Example 6 we mention that g ı 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 ı 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 . 1; 1 and OE1; 1/.
Splitting the limit for x ! x 0 into the unilateral limits x ! x 0 and x ! x 0 C in the definition of derivatives, one may define one-sided diferentiability. Recall that the left resp. right derivative of f at x 0 2 R is defined by 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 .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 and g.y/ WD 2 OE0;1/ .y/. Then g is right differentiable at f .0/ D 0, and f is even differentiable in the classical sense at x 0 D 0. The sequence .x n / n defined by x n D 1=n converges to 0 from above as n ! 1. However, shows that g ı 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 W R ! R is one-sided differentiable at x 0 , and g W R ! R is differentiable at f .x 0 /, then g ı f W R ! R is one-sided differentiable (in the same sense as f ) at x 0 . We leave the proof to the reader.

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 W OE0,1 ! OE0,1 be the Riemann function from Example 5, and g W OE0,1 ! R the characteristic function g.y/ WD .0,1 .y/. Then g ı f is the Dirichlet function which is not Riemann integrable. From Lebesgue's criterion it follows that g ı 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 ı f .
Even more interesting is the fact that, as several times before, we cannot change the order in the composition. Clearly, f is (even Lipschitz) continuous. Composing f with the Riemann integrable characteristic function g.y/ WD f0g .y/, we end up with the characteristic function g ı f D C˛o f C˛which is not Riemann integrable, because its discontinuity set C˛has positive measure. 8 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 W OE0,1 ! OE0,1 associated to the ternary Cantor nullset C is surjective, continuous, and increasing, but not injective. The strict Cantor function W OE0,1 ! OE0,1 given by .x/ WD 1 2 .x C .x// is even bijective, continuous, and strictly increasing (see, e.g., [5,Example 8.16]). Being monotone, the function has bounded variation; however, it is not absolutely continuous, since it maps the nullset C into a set of positive measure, so it lacks the Luzin property. 8 Here we use the fact that a characteristic function D is discontinuous precisely on the boundary @D of D, and @C˛D C˛, since C˛is closed without interior points.
Choose a nonmeasurable set 9 E .C/. Since is a homeomorphism, we deduce then that D WD 1 .E/ C, and so D is a nullset.

Example 10
With , E and D as above, we define f; g W OE0,1 ! OE0,1 by f WD 1 and g WD D . Both functions are obviously Lebesgue measurable. On the other hand, since the composition g ı f D E is the characteristic function of a nonmeasurable set, it cannot be measurable.
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 ı 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.
It is well-known that f is Lebesgue integrable on OE0,1 with integral 2. However, composing f with the integrable function g.y/ WD y 2 gives a nonintegrable function.
Note that the function g is even analytic and monotone (on .0; 1/). 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.

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 if 10  Example 12 Let f; g W R ! R be defined by f .x/ WD x 2 and g.y/ WD e y . Then f is closed, but not open, while g is open, but not closed. However, the composition g ı f W R ! R is neither closed nor open, since .g ı f /.R/ D .0,1.

Example 13
Likewise, let f; g W R ! R be defined by f .x/ WD arctanx and g.y/ WD y 2 . Then f is open, but not closed, while g is closed, but not open. However, the composition g ı f W R ! R is neither closed nor open, since .g ı f /.R/ D OE0; 2 =4/.
Another interesting class are functions f with primitive, i.e., f D F 0 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 W OE0,1 ! R defined by So the function in Example 6 is f D f 2 . The function f is continuous for no value of , has the intermediate value property for 1 Ä Ä 1, and has a primitive only for D 0. In fact, a primitive of f D f 0 is given in explicit form by as may be verified by a straightforward calculation. We use this function to show that g ı f need not have a primitive even if f has a primitive and g is very smooth.

Example 14
Let f D f 0 W OE0,1 ! OE 1,1 be the function we just considered, and let g.y/ WD y 2 . We claim that g ı f has no primitive. In fact, it is not hard to verify that h WD g ı f has the primitive but only on the interval .0,1. Calculating the derivative of H at zero directly yields This means that H 0 .x/ has the "wrong value" in zero, so the square h D f 2 has, in contrast to f , no primitive. 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 ı 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 W OE0,1 ! OE0,1 be the continuous increasing Cantor function which we already considered before Example 10. Being continuous, f has certainly a primitive. Putting h n WD 3 n and ı n WD 12 n , we define a function g W OE0,1 ! R in such a way that the graph of g over every interval I n WD OE2 n ı n ; 2 n C ı n is a triangle with vertices .2 n ı n ; 0/, .2 n C ı n ; 0/, and .2 n ; h n /. The function g can be given explicity on I n by g.y/ WD 8 < : 0 f o r 2 .nC1/ C ı nC1 Ä y < 2 n ı n ; h n ı n .y 2 n / C h n for 2 n ı n Ä y < 2 n ; h n ı .2 n y/ C h n for 2 n Ä y < 2 n C ı n : Finally, we set g.y/ D 0 for y D 0 or 1=2 C 1=12 Ä y Ä 1. Since the function g is continuous on OEa; 1 for every a 2 .0,1/, it has a primitive G on .0,1 which may be calculated through the formula However, being unbounded near zero, the function g is certainly not continuous on the whole interval OE0,1. Nevertheless, a somewhat cumbersome computation shows that we may extend G to a primitive of g on OE0,1 if we put G.0/ WD 0.
In this way we have constructed two functions f and g with primitives, where only f is continuous. 11 Let us now show that the composition h WD g ı f W OE0,1 ! R does not have a primitive on OE0,1. In fact, suppose that where we used the fact that f satisfies f .OE3 k ; 2 3 k / D f2 k g. But the continuity of H on OE0,1 implies that the first term of this expression tends to H.1/ H.0/ as n ! 1 which is impossible.

Necessary conditions
Our main objective in the preceding sections may be formulated as follows: if we consider all functions f W OEa; b ! R from a certain function class XOEa; b, can you give a sufficient condition on a function g W R ! R such that also g ı f belongs to XOEa; 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 ı f 2 XOEa; b for all f 2 XOEa; b. To this end, we formally introduce the perturbation set P.X/ WD fg W g ı f 2 X for all f 2 Xg which describes the maximal possible perturbation which does not take functions from X outside X. For some classes X the description of 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/ D x belongs to X, then clearly P.X/ Â X. Conversely, if X is closed under compositions, the inclusion P.X/ Ã X holds. As a consequence, we immediately deduce that Consequently, whenever a function g W R ! R is not locally Lipschitz, we can find an absolutely continuous function f such that g ı 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˛D 1 in Example 2.
Denoting by the set of all functions with primitive, the problem of characterizing P./ was open for a long time. It is clear that every affine function g.y/ D˛y Cˇwith fixed˛;ˇ2 R belongs to P./: if F is a primitive of f , the function H.x/ WD˛F .x/ Cˇx is a primitive of h D g ı f . The solution of this problem is rather surprising [1]: the set P./ contains only affine functions! Consequently, whenever a function g W R ! R is not affine, we can find a function f with a primitive such that g ı f does not have a primitive. This explains in turn why even such a well-behaved analytic function like g.y/ D 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 W I ! J is continuous and onto, and g ı f W I ! R has a property we are interested in; for which properties can we infer that g W J ! 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 Thus, f is continuous if and only if .f / is pathwise connected, 12 and f is a Darboux function if .f / is connected. The converse of the latter assertion is not true, since one may construct rather counter-intuitive Darboux functions f W R ! 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 W I ! J is continuous and onto, 13 and g ı f W I ! R is continuous, then also g is continuous.
If f W I ! J is continuous and onto, and g ı f W I ! R has a connected graph, then also g has a connected graph. If f W I ! J is continuous and onto, and g ı f W I ! R is a Darboux function, then also g is a Darboux function. If f W I ! J is a Darboux function and onto, g W J ! R is a Darboux function, and g ı f W I ! 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 equalitŷ ..g ı f // D f.f .x/; g.f .x/// W x 2 I g D f.y; g.y// W y 2 J g D .g/; whereˆW I R ! J R is defined byˆ.x; y/ WD .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 W I ! J is a Darboux function, and both g W J ! R and g ı f W I ! 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 W I ! J is continuous, and g W J ! R has a connected graph, then also g ı f W I ! R has a connected graph [6]; second, if f W I ! J has a connected graph, and g W J ! R is continuous, then also g ı f W I ! 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 WD .OE0,1 f0g/ [ f.0,1/g [ 1 [ nD1 .f1=ng OE0,1/ and a connected graph with a squeezed shifted oscillation function g W OE0,1 ! R with connected graph such that the composition g ı f W X ! 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 ı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 W R ! R which are almost trivial, but even hold for maps between arbitrary topological spaces: If g ı f is open, and g is injective and continuous, then also f is open.
If g ı 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.
Then g is continuous and .g ı f /.x/ D x is open (and even a homeomorphism on R). However, g is not injective, and f is not open.
Define f W R ! R and g W R ! R by f .x/ WD e x and g.y/ WD y 2 . Then f is continuous and .g ı f /.x/ D e 2x is open (and even a homeomorphism between R and .0; 1/). However, f is not surjective, and g is not open.