Weierstrass's Monster
27 comments
·January 24, 2025seanhunter
The Weierstrass function is cool but the undisputed champion of calculus counterexamples has to be the Dirichlet function[1]
f(x) = 1 if x is rational, 0 otherwise.
It is defined over all real numbers but continuous nowhere. Also if you take the Dirichlet function and multiply it by x so you get
g(x) = x if x is rational, 0 otherwise
…then you have something that is continuous at exactly one place (0) and nowhere else, which also is pretty spectacular.
shoo
> continuous at exactly one place (0) and nowhere else
after a bit of thought, less surprising if we regard g(x) as a function that is defined pointwise as either i(x) = x or z(x) = 0 depending on some highly discontinuous property of x
z(x) = 0 is a pretty good approximation of i(x) = x at x=0
philomath_mn
Nice.
Reminds me of the discrete metric in my Real Analysis course: distance is 0 if it is the same point, 1 otherwise.
We used to joke that it was the perfect metric for finding weird counter examples
unkulunkulu
there is a whole book “counterexamples in analysis”, basically for each theorem they find why every condition is required. these functions and ideas based on them are indispensable.
this weierstrass function is definitely a mind bender I remember from high school.
dgoldstein0
yup, that's a standard example / counterexample. Called the discrete metric. If you are trying to prove something about metric spaces, you should try your statement on that metric. A lot of things that seem true because they intuitively sound right with Euclidean distance break with the discrete metric.
pfdietz
A related weird function is Thomae's Function, also known as the Popcorn Function.
https://en.wikipedia.org/wiki/Thomae%27s_function
It is discontinuous at every rational number, but continuous at every irrational number.
seanhunter
That function is very beautiful. I love John Conway’s name for it “Stars over Babylon”.
thomassmith65
Here's Weierstrass in Python: https://scipython.com/blog/the-weierstrass-function
I wonder what they sound like as audio.
Edit: apparently it sounds like this https://youtu.be/vWmZnlPQK14
emmanueloga_
My attempt at nice looking TS version:
function sum(f: (x: number) => number, upper = 500) {
let sum = 0;
for (let n = 0; n < upper; n++) sum += f(n);
return sum;
}
const weierstrass = (x: number, a = 0.5, b = 3) =>
sum(n => a ** n * Math.cos(b ** n * x));
waveBidder
honestly less terrible than I was expecting
praptak
Audio spectrum is bounded, so we are only hearing the first few terms of the series that make up the function (the coefficient under sine grows exponentially with n).
You could even replace the audible part with Chopin (or anything else, even f(x)=0) to get a Weierstrass-like function which sounds like Chopin (or silence) but is still not differentiable anywhere.
thomassmith65
What piqued my interest is that the illustration in the article looks a lot like a typical organic audio waveform. That's unusual.
At a lower pitch, with some variation in pitch and amplitude, it probably sounds nicer.
emmanueloga_
At some frequencies sounds like a more (or less) chip-crushed church organ.
awanderingmind
Many mathematicians dismissed the function. It was an anomaly, they said — the work of a pedant, mathematically useless.
This is low-key hilarious given how much of mathematics seems like pedantry to an outsider.andrewhalle
Here’s a really cool thing about continuous-everywhere differentiable-nowhere functions. A consequence of the Baire Category Theorem is that most continuous functions are nowhere-differentiable (in the same sense that “most” real numbers are irrational).
The familiar functions from calculus are the vanishing minority of continuous functions.
croes
Did I miss the mentioning of the actual function?
rmrfchik
They even don't let you select and search the word. What a ... strange choice of ui/ux.
emmanueloga_
+1, it the obvious thing missing in the article!
graycat
A favorite on my bookshelf:
Bernard R.\ Gelbaum and John M.\ H.\ Olmsted, {\it Counterexamples in Analysis,\/} Holden-Day, San Francisco, 1964.\ \
cyberax
My favorite counter-example in math is https://en.wikipedia.org/wiki/Schwarz_lantern
Intuitively, you'd think that the surface area in 3D can be approximated by using a series of converging polyhedra, but that's not the case.
t234oi324324
I've increasingly come to doubt the utility of all these things.
Real numbers and Lesbesgue integration that stem out of 19th c. analysis came before Computability was a thing... and it turns out that all but a measure 0 set of real-numbers are actually computable.
So all these things that we worry about don't even "exist" in a computational sense.
Mathematicians haven't come to terms with this (barring non-standard analysis etc.), and I suspect this is one of the reasons it's losing mind-share.
tsimionescu
Note that "computable" just means "computable by a Turing machine or equivalent system", at this time. We don't know if we are missing some other form of computation that goes beyond the abilities of a Turing machine, that could upend the whole concept. And given that we haven't proven that general human thinking is a computable process, there is at least one significant candidate for possible computation beyond Turing machines.
Note that I don't personally think it's likely that our thinking goes beyond the capabilities of a Turing machine, not at all. But I also think it would be premature to throw out all mathematics that doesn't conform to Turing machine computability before we are more sure that this is the best possible model.
And even if it were, there is also the question of whether physical processes are computable or not. Right now there are plenty of physical processes where our best and only reliable models for predicting their behavior require assumptions from calculus, like the existence of all real numbers. For example, there is no successful formulation of quantum mechanics where the distance between two particles moving relative to each other can be constrained to any subset of the [minDistance, maxDistance] interval of the real number line. Which means that, as the particles move away from each other, at some times the distance between them will have to be an uncomputable number (and given their density in the real number line, this will be approximately all the time).
magneticnorth
>> and it turns out that all but a measure 0 set of real-numbers are actually computable.
This is the wrong way around. The computable numbers have measure 0. In fact, they are countable.
The non-computable real numbers have full measure.
(proof: by definition, computable numbers are generated by a program, which can be represented by a finite number of bits. The set of finite numbers is countable).
xscott
What could it mean to have full measure but nobody can provide any method of generating the digits to a single element of the set? We can define things like Chaitin's constants, but we don't know very many digits, and Chaitin's constants are countable. We claim there are these bountiful numbers, more numerous than the countables, but can't even specify the value of any of them.
I suspect some future generation is going to decide that diagonalizaation is based on questionable axioms. It leads to invisible pink elephants.
zmgsabst
They’re not finitely describable — for any member of that set, no matter how many digits you articulate, you’ve named a rational number.
The same is true even for numbers that have finite predicates defining them — because there’s only measure zero finite predicates.
Most real numbers are indescribable sequences (ie, not finitely describable), so it’s not surprising we can’t describe them. That’s what happens when you construct something by including all possible infinite sequences — almost all of them are total gibberish.
Diagonalization is a consequence of that: we have a schema of descriptions forming our predicate and prove no matter how we index reals by the integers, there’s more stuff out there. To get rid of that, we need to stop completing sequences.
Most people aren’t in favor of that finitism/constructive approach now — so I’m not sure why that would change.
There's a wonderful book on Mathematical counterexamples in French[0], meant for undergrad/engineering school hopefuls.
So many of the continuity counter-examples are throwing Weierstrass at the wall and getting something to stick. It's fun but also feels a bit like cheating.
I do recommend this book for any french-speaking mathematician-adjacent person though. Real great dictionary for remembering why certain things only work in one direction.
[0] Les contre-exemples en mathématiques: https://www.editions-ellipses.fr/accueil/5328-les-contre-exe...