In Praise of y = x^{α} sin(\frac{1}{x}) H. Turgay Kaptanoğlu

Counterexamples have great educational value, because they serve to illustrate the limits of mathematical facts. Every mathematics course should include counterexamples that convince students that some misconceptions are false, the converse of a theorem does not hold, and each hypothesis of a theorem is essential.

The function s : I → ℝ defined by

s(x) = \{ \begin{matrix}x^{α} sin(\frac{1}{x}), & if x ≠ 0; \\ 0, & if x = 0; \end{matrix}

for α > 0 is an inexhaustible source of counterexamples and examples for a wide variety of results in analysis. The domain I is always an interval containing 0. If x^{α} makes sense for negative x, then I is ℝ; otherwise it is [0, ∞); or it is a subinterval of one of these that contains 0. We describe some examples that we have encountered while teaching undergraduate calculus, advanced calculus, and analysis courses.

What makes s so appealing is its behavior near 0; s makes infinitely many oscillations as x → 0 within I, no matter how small I may be. The factor x^{α} controls the height of the graph above and below the x-axis. Since sine takes both positive and negative values, the functions y = x^{α} and y = −x^{α} are the envelopes of the graph of s.

The zeros of s apart from 0 are among the zeros of y = sin(1/x). Thus for x ≠ 0, we have s(x) = 0 when 1/x = kπ, that is, when x = 1/(kπ) for k a nonzero integer, and k a positive integer if α does not allow x to be negative. Let’s call these zeros z_{k}. The smallest positive value of k, which is 1, shows that there is a largest zero of s. This is a hint as to the behavior of s as x → ∞, which is also contrary to the first impression that oscillations continue with growing amplitude as x gets large. The fact is that there are no oscillations beyond z_{1}, and the behavior of s for large x depends on the value of α. L’Hôpital Rule yields

lim_{x→∞} s(x) = lim_{t→0^{+}} \frac{sin t}{t^{α}} = L,

where L = 0 for 0 < α < 1, L = 1 for α = 1, and L = ∞ for α > 1. Similar results are obtained as x → −∞ for those values of α for which x^{α} makes sense.

In each of the following examples or counterexamples, only the value of α given, and the function is always denoted by s irrespective of the value of α. We start with the more elementary and progress to the more involved.

A1. An honest-to-goodness example for the Squeeze Theorem for limits. Any value of α works, but we work out the case α = 1. Since −1 ≤ sin(1/x) ≤ 1, s satisfies −x ≤ s(x) ≤ x. Then lim_{x→0}(−x) = lim_{x→0} x = 0 implies lim_{x→0} s(x) = 0 = s(0). Thus s is continuous at 0. For other values of α, we might have to consider limits only from the right, but we still have at least one-sided continuity. The general s is also a good nontrivial example to a familiar consequence of the Squeeze Theorem: a product in which one factor has limit 0 and the other factor is bounded has limit 0.

A2. A continuous function that is not differentiable. The simplest s is the one with α = 1. Continuity was shown in A1. Since the limit

lim_{x→0} \frac{s(x) − 0}{x − 0} = lim_{x→0} sin(\frac{1}{x})

does not exist, s is not differentiable at 0. This conclusion holds for all α ≥ 1.

A3. A function for which the easy proof of the Chain Rule fails. We take α = 2. By the definition of the derivative and A1, we have

s′(0) = lim_{x→0} \frac{s(x) − s(0)}{x − 0} = lim_{x→0} x sin(\frac{1}{x}) = 0.

Let f be any function that is differentiable at 0. The Chain Rule gives (f ∘ s)′(0) = f′(s(0))s′(0) = f′(0) · 0 = 0. To prove this, one might first try

(f ∘ s)′(0) = lim_{x→0} \frac{f(s(x)) − f(s(0))}{x} = lim_{x→0} \frac{f(s(x)) − f(s(0))}{s(x) − s(0)} \frac{s(x) − s(0)}{x − 0}

= lim_{x→0} \frac{f(s(x)) − f(0)}{s(x)} lim_{x→0} \frac{s(x)}{x}.

In the last line, the second limit is 0; here x never takes the value 0. As x → 0, at each z_{k}, the numerator and the denominator of the expression in the first limit become 0 and their ratio is undefined. In other words, lim_{x→0} in which x ≠ 0 cannot be replaced by lim_{s(x)→0}

there. Thus the first limit does not exist. The problem with this computation is trying to evaluate the limit of a product as a product of limits without checking whether each of the individual limits exists. This difficulty can be overcome by approximating s by a linear function near 0.

A4. Limit of a product of two functions versus the product of their limits. Equality requires the existence of all three limits as proved in A3.

A5. A function that is differentiable with a discontinuous derivative. Here again α = 2 furnishes a good example. We have

s′(x) = 2x sin(\frac{1}{x}) − cos(\frac{1}{x}) (x ≠ 0),

and s′(0) = 0 from A3. Thus s is differentiable everywhere. But lim_{x→0} s′(x) does not exist

because of the oscillatory behavior of cos(1/x) near 0. In fact, if lim_{x→0} s′(x) existed, it would

be equal to s′(0) by an application of L’Hopital Rule. So s′ is not continuous at 0; said differently, s is not of class C^{1}.

Higher values of α give functions that are n times differentiable but not in C^{n}, for each given positive integer n. For example, with α = 4, s is twice differentiable, but not of class C^{2}.

The next two counterexamples are exercises in [1].

A6. A function with no local extremum at an endpoint. We take α = 1 once again and use the interval [0, ∞). The function s is differentiable on (0, ∞) with

s′(x) = sin(\frac{1}{x}) − \frac{1}{x} cos(\frac{1}{x}) (x > 0).

Then s′(z_{k}) = (−1)^{k+1}kπ, so s does not have a derivative with constant sign in any open interval with left endpoint 0. Thus s is neither increasing nor decreasing on any such interval and cannot have a local maximum or a local minimum at x = 0.

A7. A function for which a critical point is neither an extremum point nor an inflection point. We take α = 2 one more time. For x ≠ 0, s is infinitely differentiable; in particular,

s′′(x) = (2 − \frac{1}{x^{2}} ) sin(\frac{1}{x}) − \frac{2}{x} cos(\frac{1}{x}) (x ≠ 0).

However s′ is discontinuous at 0 by A5; hence s′′(0) does not exist. Since s′(0) = 0, 0 is a critical point. As in A6, a consideration of s′(z_{k}) shows that 0 is not a local extremum point. Moreover s′′(z_{k}) = 2(−1)^{k+1}kπ. By the same argument used in A6, there is no open interval with one endpoint at 0 on which s′′ has constant sign. Then 0 cannot be an inflection point although the graph of s has a tangent line there.

We can elaborate further by taking α = 4. Then 0 is a critical point, and even s′′(0) = 0. Repeating our argument shows that 0 is not a local extremum point nor an inflection point.

A8. A differentiable function of two variables with a discontinuous derivative. This is a two-variable analog of A5. We consider the function s : ℝ^{2} → ℝ defined by

s(x, y) = \{ \begin{matrix}(x^{2} + y^{2}) sin(\frac{1}{\sqrt{x^{2} + y^{2}}} ), & if (x, y) ≠ (0, 0); \\ 0, & if (x, y) = (0, 0). \end{matrix}

It is straightforward to compute s_{x}(0, 0) = 0, s_{y}(0, 0) = 0, and

\frac{∂s}{∂x}(x, y) = 2x sin(\frac{1}{\sqrt{x^{2} + y^{2}}} ) − \frac{x}{\sqrt{x^{2} + y^{2}}} cos(\frac{1}{\sqrt{x^{2} + y^{2}}} ),
\frac{∂s}{∂y} (x, y) = 2y sin(\frac{1}{\sqrt{x^{2} + y^{2}}} ) − \frac{y}{\sqrt{x^{2} + y^{2}}} cos(\frac{1}{\sqrt{x^{2} + y^{2}}} ).

Neither s_{x} nor s_{y} is continuous at (0, 0), because, for example, the second term in s_{x} does not have a limit as x → 0 along y = 0. On the other hand,

lim_{\sqrt{x^{2}+y^{2}}→0} \frac{|s(x, y) − 0 − 0x − 0y|}{\sqrt{x^{2} + y^{2}}} = lim_{\sqrt{x^{2}+y^{2}}→0}(x^{2} + y^{2})^{3/2} sin(\frac{1}{\sqrt{x^{2} + y^{2}}} ) = 0

shows that s is differentiable at (0, 0) even though it is not of class C^{1}.

A9. A function of two variables to which the Mean Value Theorm does not apply. The particular multi-variable version of the Mean Value Theorem we consider is this: If an open set U ⊂ ℝ^{n} contains the line segment between two of its points A and B, then for a differentiable function f on U there is a point C on the open line segment such that

f(A) − f(B) = ∑_{j=1}^{n}(D_{j}f)(C)(B_{j} − A_{j}). Now we let

s(x, y) = \{ \begin{matrix}x^{1/3}y^{1/3} sin(\frac{1}{\sqrt{x^{2} + y^{2}}} ), & if (x, y) ≠ (0, 0); \\ 0, & if (x, y) = (0, 0). \end{matrix}

As in A8, we compute s_{x}(0, 0) = 0, s_{y}(0, 0) = 0, and

\frac{∂s}{∂x}(x, y) = \frac{y^{1/3}}{3x^{2/3}} sin(\frac{1}{\sqrt{x^{2} + y^{2}}} ) − \frac{x^{4/3}y^{1/3}}{(x^{2} + y^{2})^{3/2}} cos(\frac{1}{\sqrt{x^{2} + y^{2}}} ),

\frac{∂s}{∂y} (x, y) = \frac{x^{1/3}}{3y^{2/3}} sin(\frac{1}{\sqrt{x^{2} + y^{2}}} ) − \frac{x^{1/3}y^{4/3}}{(x^{2} + y^{2})^{3/2}} cos(\frac{1}{\sqrt{x^{2} + y^{2}}} ).

Yet s is not differentiable at (0, 0). To this end, let x = (1 + t^{2})^{−1/2}(π/2 + 2nπ)^{−1} for integers n and some real t, and let y = tx. Thus x → 0 as n → ∞, and sin(x^{2} +y^{2})^{−1/2} = 1 for any n. Then

lim_{n→∞} \frac{|s(x, y) − 0 − 0x − 0y|}{\sqrt{x^{2} + y^{2}}} = lim_{x→0} \frac{x^{2/3}t^{1/3}}{|x|\sqrt{1 + t^{2}}} = lim_{x→0} \frac{t^{1/3}}{|x|^{1/3}\sqrt{1 + t^{2}}}

does not exist, which implies that s is not differentiable at (0, 0).

Now choose b = 1/(\sqrt{2}π), so that sin(1/\sqrt{b^{2} + b^{2}}) = 0 and cos(1/\sqrt{b^{2} + b^{2}}) = −1. If C = (c, c) is a point on the line segment joining A = (0, 0) and B = (b, b), then

s_{x}(C)b + s_{y}(C)b = 2s_{x}(c, c)b = −\frac{2c^{5/3}}{2^{3/2}c^{3}} (−1)\frac{1}{\sqrt{2}π} = \frac{1}{2πc^{4/3}} ≠ 0

even though s(B) − s(A) = 0. Thus the differentiability assumption in the Mean Value Theorem cannot be omitted.

A10. A uniformly continuous function with unbounded derivative. A straightforward application of the Mean Value Theorem shows that a continuous function with bounded derivative is uniformly continuous. That the converse is not true can be shown by taking α = 4/3 on the interval I = [−1, 1]. Continuity of s and compactness of the interval imply that s is uniformly continuous on I. However

s′(x) = \frac{4}{3}x^{1/3} sin(\frac{1}{x}) − \frac{1}{x^{2/3}} cos(\frac{1}{x}) (x ≠ 0)

is unbounded in any open interval with one endpoint at 0 although s′(0) = 0.

A11. A function that is not differentiable satisfying a one-point Lipschitz condition. A2 shows that s is not differentiable when α = 1. However it satisfies a one-point Lipschitz condition of order 1 at 0 since

|s(x) − s(0)| = |x sin(\frac{1}{x})| ≤ |x| = 1|x − 0|^{1} (x ≠ 0).

Thus there is a difference between satisfying a property at a point and on an interval containing the point. A function satisfying a Lipschitz condition of order 1 on an interval would be differentiable with bounded derivative on that interval. We will have one more example of this kind in the second part.

A12. A continuous function that is not of bounded variation. We know s is continuous when α = 1. Consider a_{n} = (π/2 + nπ)^{−1} for n = 0, 1, 2, . . .. Then 0 < a_{n} < 1 and sin(1/a_{n}) = (−1)^{n} for every n. Since

∑_{n=1}^{N} |s(a_{n−1}) − s(a_{n})| = |\frac{2}{π} + \frac{2}{3π} | + |\frac{2}{3π} + \frac{2}{5π} | + ⋯ + |\frac{2}{(2N − 1)π} + \frac{2}{(2N + 1)π} |

= \frac{4}{π} (\frac{1}{2} + \frac{1}{3} + \frac{1}{5} + ⋯ + \frac{1}{2N − 1} + \frac{1}{2(2N + 1)}),

the total variation of s over [0, 1] is not finite.

A13. A function whose graph is not a rectifiable curve. Nothing new need be said here; the s in A12 has a graph of infinite length.

A14. An absolutely continuous function that is not Lipschitz. We consider α = 3/2 on [0, 1], which gives

s′(x) = \frac{3}{2}\sqrt{x} sin(\frac{1}{x}) − \frac{1}{\sqrt{x}} cos(\frac{1}{x}) (x > 0)

and s′(0) = 0. Since s′ is not bounded, s is not Lipschitz.

The graph of s is steepest where s′′(x) = 0, and there is one such point c_{k} lying a little to the left of each z_{k}. We have [(k + 1)π]^{−1} << c_{k} < [kπ]^{−1} for k = 1, 2, . . .. The distance between any two consecutive c_{k}’s is less than 1/(k^{2}π), so let’s take disjoint intervals [a_{k}, b_{k}] containing c_{k} of length at most δ/(k^{2}π). The total length of these intervals is at most

\frac{δ}{π} ∑_{k=1}^{∞} \frac{1}{k^{2}} = \frac{δπ}{6} < δ.

The Mean Value Theorem provides us with d_{k} such that s′(d_{k})(b_{k} − a_{k}) = s(b_{k}) − s(a_{k}). We have

|s′(x)| ≤ \frac{3}{2}\sqrt{x} + \frac{1}{\sqrt{x}}  and  |s′(d_{k})| ≤ \frac{3}{2} \frac{1}{\sqrt{kπ}} + \sqrt{(k + 1)π} ≤ 2\sqrt{kπ}.

Then

∑_{k=1}^{∞} |s(b_{k}) − s(a_{k})| ≤ ∑_{k=1}^{∞} |s′(d_{k})|(b_{k} − a_{k}) ≤ ∑_{k=1}^{∞} 2\sqrt{kπ} \frac{δ}{k^{2}π} = \frac{2δ}{\sqrt{π}} ∑_{k=1}^{∞} \frac{1}{k^{3/2}} = δM.

Finally, picking δ < min{1, ε/M} for a given ε > 0 shows that s is absolutely continuous over [0, 1].

The next examples concern functions that are in the same spirit as s but are somewhat different from it.

B1. A differentiable function with an extremum value at an interior point at which its derivative does not have a simple change of sign. Let

r(x) = \{ \begin{matrix}2x^{2} + x^{2} sin(\frac{1}{x}), & if x ≠ 0; \\ 0, & if x = 0. \end{matrix}

The envelopes of r are y = 3x^{2} and y = x^{2}; thus r has an absolute and relative minimum at x = 0. We compute r′(0) = 0 and

r′(x) = 4x + 2x sin(\frac{1}{x}) − cos(\frac{1}{x}) (x ≠ 0).

We have r′(z_{k}) = 4(kπ)^{−1} + (−1)^{k+1}. When k ≥ 2, r′ > 0 for odd k and r′ < 0 for even k. Thus r′ changes sign arbitrarily often in any interval containing 0.

B2. A nonincreasing function with a positive derivative. The positivity of the derivative is at a single point of course, not on an interval. We let

r(x) = \{ \begin{matrix}x + 2x^{2} sin(\frac{1}{x}), & if x ≠ 0; \\ 0, & if x = 0. \end{matrix}

Then r′(0) = 1 and

r′(x) = 1 + 2x sin(\frac{1}{x}) − 4 cos(\frac{1}{x}) (x ≠ 0).

Also the envelopes of r are y = x(1 + 2x) and y = x(1 − 2x); these help us to visualize the following computation.

Let a = [3π/2 + 2(k + 1)π]^{−1}, b = [π/2 + 2(k + 1)π]^{−1}, and c = [3π/2 + 2kπ]^{−1} for k an integer so that a < b < c. Letting p = 3π/2 + 2kπ > 0, we have

r(a) = \frac{p − 2 + 2π}{(p + 2π)^{2}} ,  r(b) = \frac{p + 2 + π}{(p + π)^{2}} ,  and  r(c) = \frac{p − 2}{p^{2}}.

The numerators of the differences r(c)−r(a) and r(b)−r(c) are quadratic polynomials in p with positive coefficients for p^{2}. The denominators are already positive. These differences are positive for p large, which corresponds to k large which in turn occurs when a, b, and c are close to 0. Thus, every interval containing 0 contains points a, b, and c such that 0 < a < b < c and r(a) < r(b) > r(c). We conclude that r is increasing on no interval containing 0 although s′(0) > 0. The calculation also shows that the coefficient 2 in the definition of r cannot be replaced by 1.

B3. A differentiable function to which the Inverse Function Theorem does not apply. The r of B2 works here too. The key point is that r′ is not continuous at 0. We showed in B2 that r(a) < r(c) < r(b), but c is not between a and b. The Intermediate Value Theorem gives a d betwen a and b such that r(d) = r(c). Hence r is not one-to-one and thus is not invertible in any interval containing 0.

B4. A function for which the Fundamental Theorem of Calculus fails. We need to start with a discontinuous function. Let r be the derivative of s in A5 with the modification r(0) = 1. Define

R(x) = ∫_{−1/π}^{x} r(t) dt (x ∈ ℝ).

Then R(x) = s(x) = x^{2} sin(1/x) for x < 0 and

R(0) = ∫_{−1/π}^{0} r(t) dt = lim_{x→0^{−}} ∫_{−1/π}^{x} r(t) dt = lim_{x→0^{−}} ∫_{−1/π}^{x}[2t sin(\frac{1}{t}) − cos(\frac{1}{t})] dt

= lim_{x→0^{−}}[t^{2} sin(\frac{1}{t})]_{−1/π}^{x} = lim_{x→0^{−}} x^{2} sin(\frac{1}{x}) = 0.

Similarly, ∫_{0}^{1/π} r(t) dt = 0. So for x > 0,

R(x) = ∫_{−1/π}^{0} r(t) dt + ∫_{0}^{x} r(t) dt = ∫_{0}^{x} r(t) dt = ∫_{0}^{1/π} r(t) dt − ∫_{x}^{1/π} r(t) dt

= − ∫_{x}^{1/π} r(t) dt = x^{2} sin(\frac{1}{x}) = s(x).

Thus

R′(0) = lim_{h→0} \frac{R(h) − R(0)}{h} = lim_{h→0} h sin(\frac{1}{h}) = 0.

However r(0) = 1.

B5. A connected set that is not path connected. With r(x) = sin(1/x), the set consisting of the graph of r and the vertical line segment {0} × [−1, 1] in ℝ^{2} is connected, but not path connected.

Reference

[1] Robert A. Adams, Calculus: A Complete Course, 4th edition, Addison-Wesley, Don Mills, Ontario, 1999.

Mathematics Department, Middle East Technical University, Ankara 06531 Turkey kaptan@math.metu.edu.tr