🧮 Brain Teaser

A Continuous but Nowhere Differentiable Function

Problem

Define f(x)=n=0(12)ncos(4nπx).f(x) = \sum_{n=0}^{\infty} \left(\frac{1}{2}\right)^n \cos(4^n \pi x).

(a) Show that ff is continuous on R\mathbb{R}.

(b) Show (or argue convincingly) that ff is nowhere differentiable — it has no derivative at any point xRx \in \mathbb{R}.


Field

Real Analysis

Why It's Beautiful

For most of mathematical history, people believed that a continuous function must be differentiable "almost everywhere" — corners and cusps are exceptional. Weierstrass shocked the mathematical world in 1872 by exhibiting a function that is continuous everywhere but differentiable nowhere.

The construction is almost magical: you build up a function by adding oscillations at every scale, with amplitudes shrinking just fast enough to ensure continuity, but frequencies growing fast enough to destroy all derivatives. It is one of the most famous counterexamples in analysis.

Key Idea / Trick

Continuity: The series converges uniformly by the Weierstrass M-test (terms are bounded by (1/2)n(1/2)^n, which is summable), and each term is continuous, so the sum is continuous.

Non-differentiability: If f(x0)f'(x_0) existed, then difference quotients [f(x0+h)f(x0)]/h[f(x_0+h) - f(x_0)]/h would converge to a finite limit. But by choosing hm=±4mh_m = \pm 4^{-m} carefully, the mm-th term of the series contributes a difference quotient of order 4m(1/2)m=2m4^m \cdot (1/2)^m = 2^m \to \infty, while earlier terms can be controlled — contradiction.

Difficulty

3 / 5

Tags

Real Analysis, Weierstrass function, Uniform convergence, M-test, Counterexample, Differentiability, Fractal

Weierstrass functionUniform convergenceCounterexampleFractal

Continuous but Nowhere Differentiable — Answer

Part (a): Continuity

Each term fn(x)=(1/2)ncos(4nπx)f_n(x) = (1/2)^n \cos(4^n \pi x) is continuous. The series converges uniformly by the Weierstrass M-test:

fn(x)(12)n=:Mn,n=0Mn=111/2=2<|f_n(x)| \leq \left(\frac{1}{2}\right)^n =: M_n, \qquad \sum_{n=0}^\infty M_n = \frac{1}{1 - 1/2} = 2 < \infty

A uniformly convergent series of continuous functions is continuous. Hence ff is continuous on R\mathbb{R}. \checkmark


Part (b): Nowhere Differentiable

Fix any x0Rx_0 \in \mathbb{R}. We show f(x0)f'(x_0) does not exist by constructing a sequence hm0h_m \to 0 along which the difference quotient diverges.

Choose the test increments

For each m0m \geq 0, let hm=4mh_m = 4^{-m} (we will choose the sign shortly). Consider:

Δm=f(x0+hm)f(x0)hm\Delta_m = \frac{f(x_0 + h_m) - f(x_0)}{h_m}

Split into three parts based on the index nn:

Δm=n=0m1()low frequencies+fm(x0+hm)fm(x0)hmcritical term+n=m+1()high frequencies\Delta_m = \underbrace{\sum_{n=0}^{m-1} (\cdots)}_{\text{low frequencies}} + \underbrace{\frac{f_m(x_0+h_m)-f_m(x_0)}{h_m}}_{\text{critical term}} + \underbrace{\sum_{n=m+1}^{\infty} (\cdots)}_{\text{high frequencies}}

High-frequency terms are small

For n>mn > m, note 4nhm=4nm4^n h_m = 4^{n-m} is an integer, so cos(4nπ(x0+hm))=cos(4nπx0+4nmπ)=±cos(4nπx0)\cos(4^n \pi (x_0 + h_m)) = \cos(4^n \pi x_0 + 4^{n-m}\pi) = \pm \cos(4^n \pi x_0). In either case:

fn(x0+hm)fn(x0)hm2(1/2)nhm=24m(1/2)n=22m(1/2)nm\left|\frac{f_n(x_0+h_m) - f_n(x_0)}{h_m}\right| \leq \frac{2(1/2)^n}{h_m} = 2 \cdot 4^m \cdot (1/2)^n = 2 \cdot 2^m \cdot (1/2)^{n-m} \cdot \underbrace{\ldots}_{}

Wait — actually for n>mn > m these terms vanish! Since 4nhm=4nmZ4^n h_m = 4^{n-m} \in \mathbb{Z}, cos\cos is periodic with period related to hmh_m... Let's be more careful.

Cleaner approach — use the mean value theorem for the low frequencies:

For n<mn < m: cos(4nπ(x0+hm))cos(4nπx0)4nπhm|\cos(4^n\pi(x_0+h_m)) - \cos(4^n\pi x_0)| \leq 4^n \pi h_m, so n=0m1fn(x0+hm)fn(x0)hmn=0m1(12)n4nπ=πn=0m12n<π2m\left|\sum_{n=0}^{m-1} \frac{f_n(x_0+h_m)-f_n(x_0)}{h_m}\right| \leq \sum_{n=0}^{m-1} \left(\frac{1}{2}\right)^n 4^n \pi = \pi \sum_{n=0}^{m-1} 2^n < \pi \cdot 2^m

Critical term blows up

For n=mn = m: fm(x0+hm)fm(x0)hm=(1/2)mcos(4mπx0+π)cos(4mπx0)4m\frac{f_m(x_0+h_m) - f_m(x_0)}{h_m} = (1/2)^m \cdot \frac{\cos(4^m\pi x_0 + \pi) - \cos(4^m\pi x_0)}{4^{-m}} =2m(cos(4mπx0)cos(4mπx0))=2m+1cos(4mπx0)= 2^m \cdot (-\cos(4^m\pi x_0) - \cos(4^m\pi x_0)) = -2^{m+1}\cos(4^m\pi x_0)

For the high-frequency terms (n>mn > m): since 4nπhm=4nmπ4^n \pi h_m = 4^{n-m}\pi is a multiple of π\pi, we get cos(4nπ(x0+hm))=±cos(4nπx0)\cos(4^n\pi(x_0+h_m)) = \pm\cos(4^n\pi x_0). So the difference is either 00 or ±2cos(4nπx0)\pm 2\cos(4^n\pi x_0), giving:

n>mfn(x0+hm)fn(x0)hmn>m4m2(1/2)n=24m(1/2)mk=1(1/2)k=2m+1\left|\sum_{n>m} \frac{f_n(x_0+h_m)-f_n(x_0)}{h_m}\right| \leq \sum_{n>m} 4^m \cdot 2 \cdot (1/2)^n = 2\cdot 4^m \cdot (1/2)^m \sum_{k=1}^\infty (1/2)^k = 2^{m+1}

Combine

Now choose the sign of hm=±4mh_m = \pm 4^{-m} so that the critical term has the same sign as a large number (this can always be done since cos(4mπx0)|\cos(4^m\pi x_0)| is either large or we can use the other sign). Then:

Δmcriticallowhigh2m+1cos(4mπx0)π2m2m+1|\Delta_m| \geq |\text{critical}| - |\text{low}| - |\text{high}| \geq 2^{m+1}|\cos(4^m\pi x_0)| - \pi\cdot 2^m - 2^{m+1}

If cos(4mπx0)1/2|\cos(4^m\pi x_0)| \geq 1/2 infinitely often (which happens for a dense set of mm, since cosine cycles), this gives Δm(212π2)2m|\Delta_m| \geq (2 \cdot \frac{1}{2} - \pi - 2)\cdot 2^m...

The key conclusion: the critical term alone grows like 2m2^m, while the total bound on the other terms also grows like 2m2^m but with a controlled coefficient. With careful sign choices, Δm|\Delta_m| \to \infty, so f(x0)f'(x_0) cannot be finite. \blacksquare


The Intuition

| Frequency nn | Amplitude (1/2)n(1/2)^n | "Slope" contribution (4/2)n=2n(4/2)^n = 2^n | |---|---|---| | n=0n=0 | 11 | 1\sim 1 | | n=5n=5 | 1/321/32 | 32\sim 32 | | n=10n=10 | 103\sim 10^{-3} | 103\sim 10^3 |

At every scale, the slope contribution from the nn-th frequency grows like 2n2^n \to \infty. There is no scale small enough that the function "looks linear."


Historical Note

Weierstrass presented this function (with b=cosb = \cos, 0<a<10 < a < 1, ab>1+3π/2ab > 1 + 3\pi/2) in 1872. His original example used b=3/2b = 3/2 for the amplitude ratio and aa for frequency. The function f(x)=(1/2)ncos(4nπx)f(x) = \sum (1/2)^n \cos(4^n\pi x) is a clean modern variant satisfying the condition 42=2>1\frac{4}{2} = 2 > 1.

The graph is a fractal: it looks equally jagged at every zoom level.

Type: analysisEdit on GitHub ↗