Skip to content
Tutorials Center
My learning

Topics

Lesson 36 of 37 · Projects and Practice

Project: The Weierstrass Function

Build the Weierstrass function as a uniformly convergent series, prove it is continuous with the M-test, and explore numerically why it has no tangent anywhere.

For a long time mathematicians believed a continuous function must be differentiable at most points. In 1872 Karl Weierstrass presented a function that is continuous everywhere and differentiable nowhere. In this project you build it, prove the continuity half with the tools from chapter 8, and watch the difference quotients explode.

The function

Choose 0 < a < 1 and an odd integer b with ab > 1 + 3π/2 (Weierstrass's original condition). Define

Text
W(x) = Σ_{n=0}^{∞} aⁿ cos(bⁿ π x).

Each term is a cosine whose frequency grows geometrically while its amplitude shrinks geometrically. Later, G. H. Hardy proved nowhere-differentiability under the weaker condition ab ≥ 1; we use a = 1/2, b = 3 for plots (ab = 1.5 ≥ 1), which falls under Hardy's result, and b = 13 with a = 1/2 (ab = 6.5 > 1 + 3π/2 ≈ 5.71) when we want the original hypothesis.

Part 1: continuity by the M-test

|aⁿ cos(bⁿ π x)| ≤ aⁿ, and Σ aⁿ = 1/(1 - a) < ∞. By the Weierstrass M-test the series converges uniformly on ℝ. Each partial sum is continuous, so by the uniform limit theorem W is continuous on ℝ. The tail estimate also gives a computable error bound: after N terms the error is at most a^{N+1}/(1 - a).

Python Partial sums and the guaranteed error

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Part 2: plotting the function

A plot of W on [0, 1] looks like a jagged mountain range, and zooming in shows a similar jagged structure at every scale (self-similarity: W(bx) relates to W(x) through the shifted series).

Python Zooming into the Weierstrass function

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Part 3: why there is no derivative

If W'(x₀) existed, the difference quotients (W(x₀ + h) - W(x₀))/h would converge as h → 0, so they would be bounded for small h. We check that they are not, by computing them for h = b^{-m} and growing m.

Heuristic reason: split the series at index m. The terms n < m contribute difference quotients of size roughly Σ (ab)ⁿ π ≈ (ab)^m (each term has derivative amplitude (ab)ⁿ π), which grows when ab > 1. The terms n ≥ m are small and contribute at most Σ_{n ≥ m} aⁿ·2/h, comparable to a^m b^m as well. A careful accounting that the two groups cannot cancel at every scale is what Weierstrass (and, for ab ≥ 1, Hardy) carried out; we only verify numerically, which is evidence and not a proof.

Python Difference quotients blow up

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The magnitudes grow roughly like (ab)^m = 6.5^m (there are N = 12 terms, so h smaller than 13^{-12} would hit truncation), the opposite of settling toward a derivative. This function is also a classic example for the failure of the derivative to exist despite continuity.

Extensions

  1. Try a = 0.5 with b = 2 (ab = 1): the function is still continuous, and looks rough, but the nowhere-differentiability analysis is subtler.
  2. Replace cos by a triangle wave to get a Takagi-type function, whose self-similar structure is easy to analyze.
  3. Compute the box-counting slope of the graph to estimate its fractal dimension: for this function it is 2 + ln a / ln b, which for a = 1/2, b = 3 gives about 1.37. (This is the commonly quoted dimension for the Weierstrass function; treat your numerical estimate as a rough check of it.)

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. Which tool proves the Weierstrass function is continuous?

    Each partial sum is continuous and the series converges uniformly, so the sum is continuous.
  2. 2. After N terms, the uniform error of the partial sum is at most:

    The tail is bounded by the geometric series of the M_n = a^n beyond N.
  3. 3. The terms of the series have derivatives of size about:

    Differentiating cos(b^n pi x) brings out a factor b^n pi, so the n-th term's derivative has amplitude a^n b^n pi.
  4. 4. What does this function show?

    Each partial sum is smooth and the series converges uniformly, yet the limit is nowhere differentiable. Uniform convergence of the functions alone does not control derivatives.

Summary

  • W(x) = Σ aⁿ cos(bⁿ π x) converges uniformly by the M-test, hence is continuous.
  • Partial sums are infinitely differentiable, yet their uniform limit has no derivative anywhere when ab is large enough (Weierstrass: ab > 1 + 3π/2; Hardy: ab ≥ 1).
  • Difference quotients grow like (ab)^m as the step shrinks, which numerics make visible.
  • It is the standard warning that uniform convergence does not transfer differentiability.

Next: Project: Quadrature Error Analysis