Readit News logoReadit News
seanhunter · 7 months ago
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.

[1] https://mathworld.wolfram.com/DirichletFunction.html

xigoi · 7 months ago
Even weirder is the Conway base 13 function, which not only is discontinuous everywhere, but its range when restricted to any interval is the entire set of real numbers (so its graph “fills up” the entire plane).

https://en.wikipedia.org/wiki/Conway_base_13_function

seanhunter · 7 months ago
John Conway was amazing. Such a loss that he died of COVID.

As well as the game of life, surreal numbers and other famous things, he also produced one of my favourite lesser-known proofs ever - the proof that 91 is the smallest number that looks prime, but isn’t https://youtu.be/S75VTAGKQpk?si=IW791RaeCsXSOrrK “This is an important theorem and a discovery that I’m very proud of”.

pfdietz · 7 months ago
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 · 7 months ago
That function is very beautiful. I love John Conway’s name for it “Stars over Babylon”.
philomath_mn · 7 months ago
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 · 7 months ago
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 · 7 months ago
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.
n4r9 · 7 months ago
I vaguely remember studying these as well as one that was something like:

h(a/b) = b for rationals a/b (in smallest terms), 0 otherwise

This one has the properties you mention of the Dirichlet function whilst also being unbounded in every non-empty interval of the reals.

JJMcJ · 7 months ago
g(x) is mind-bending. I can write out a proof that it is continuous at 0 and nowhere else, but it still barely makes sense.

I can understand the reactions of the late 19th Century mathematicians, though I suspect much of it was exaggerated rhetoric, not real horror.

dhosek · 7 months ago
If it were the Pythagoreans, they’d’ve thrown him out of a boat.
x3n0ph3n3 · 7 months ago
Because there is no bijection between the rationals and the reals, wouldn't that imply that there are some irrational reals with no rational between them, allowing this function to be continuous, at least in places we can't actually compute?
roserevealed · 7 months ago
That doesn't actually follow- even though the reals are uncountable, they're what's called "separable", which means that there is a countable set which is "arbitrarily good at approximating them", basically- the rationals!

So even though there are uncountable reals, for any real number, you can find rational numbers that get arbitrarily close. You can actually see this pretty easily if you think of reals in decimal notation- sqrt(2) is irrational, but

1.4, 1.41, 1.414, 1.4142, 1.41421, 1.414123, ... etc are all rational numbers that get closer and closer to sqrt(2).

So you should think of real numbers as uncountable, but nonetheless surrounded by rationals no matter how close you zoom in.

pjbeam · 7 months ago
The issue there I think is the idea of two reals having a "between."
n4r9 · 7 months ago
I'm a bit late to see this comment, but it was disappointing that none of the replies so far show why this is not true.

Take any irrational numbers x and y, and suppose for convenience that x < y.

Let d = y-x i.e. the length of the interval between x and y.

Let b be an integer so large that 1/b is less than d.

Consider fractions of the form a/b. As a increases, a/b will eventually (strictly) exceed the value of x. Suppose we fix a to be the smallest such value, i.e. (a-1)/b < x < a/b.

Adding d to both sides we get:

a/b - 1/b + d < x + d

Using the fact that 1/b < d and x + d = y, we get a/b < y.

Therefore x < a/b < y.

btilly · 7 months ago
No, those are unrelated concepts.
shoo · 7 months ago
> 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

hansbo · 7 months ago
It is unintuitive to me why the rational numbers are dense in the reals, since rational numbers are countably infinite, as opposed to the reals. I think infinity is hard to grasp.
layer8 · 7 months ago
It’s because for every pair of irrational numbers, there is a first place in their decimal representation where their digits differ, which means you can construct a number with finite decimal representation that fits between the two, which thus is rational.

In other words, it’s because while there are uncountably many irrational numbers, their representation is still only countably infinite each.

Or in yet other words, uncountable infinity is only a teensy bit larger than countable infinity, not that much larger. Consider that every prefix of an irrational number is a rational number. ;)

aithrowawaycomm · 7 months ago
In decimal form, almost every real number between 0 and 1 is zero-point followed by an infinite sequence of random digits. No computer in the universe has enough hard drive space to store an arbitrary fixed real number between 0 and 1. This is of course not true for rationals: any rational number can be saved on a big enough hard drive. In particular, given unbounded resources, we can build a computer that approximates (0,1) by storing a finite set of rational numbers, and reaches a given real number x with arbitrary nonzero error. But we will never get zero error on a physical computer.
trhway · 7 months ago
> why the rational numbers are dense in the reals

the reals are defined as limits of the sequences of rationals, and thus the rationals are dense in reals by that definition.

>since rational numbers are countably infinite

while the set of all the infinite convergent series of rationals happens to be strongly larger than countably infinite.

tromp · 7 months ago
Dense means arbitrarily close together, which is what rationals i/n and (i+1)/n are.

Deleted Comment

pfdietz · 7 months ago
Rationals are also dense in the p-adic numbers, which you can think of as the other way to form their completion, if I understand correctly (with a different notion of absolute value.)
omgwtfbyobbq · 7 months ago
I always thought using countable and uncountable was a little confusing and that introducing aleph/beth numbers would have made things clearer when those ideas were introduced.
frotaur · 7 months ago
Sorry, but I find it much easier to find a function with your property, compared to the continuous everywhere but differentiable nowhere functions.

In fact, here is an uncountable family of them :

f(x) = x^2 * rand(0,1)

Where rand(0,1) is a uniform number between 0 and 1, sampled for every x.

seanhunter · 7 months ago
Introducing a stochastic function is cheating. You expect calculus to break if you just throw in stochastic functions willy-nilly, so that doesn’t challenge my intuition at all.
Someone · 7 months ago
Some of those are continuous and differentiable everywhere. Examples:

  f(x) = 0
  f(x) = ½ x²
Also: doesn’t the claim that you can pick such a function require an extreme version of the axiom of choice, where you claim you can pick an element of each set in a set of sets that has uncountably many items?

rq1 · 7 months ago
No mention of the Cantor set (and its variants) indicator functions?
seanhunter · 7 months ago
Well yes. The thing I particularly like about the Dirichlet function is it’s so simple to state and yet just completely breaks my intuition about so many things.
rtpg · 7 months ago
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...

daquisu · 7 months ago
It is interesting how France became so focused on analysis and properly proving theorems and stuff, while the applications don't have the same highlight in prépa.

One professor of mine commented that most French engineers are better mathematicians than most mathematicians in Brazil.

It is the opposite of what the linked article mentions that was happening in Weierstrass' time.

mbeex · 7 months ago
Cannot compare, because I own only the following ones:

https://www.amazon.com/Counterexamples-Analysis-Dover-Books-...

Weierstrass function is also there, but exactly this one contains an error... :)

https://math.stackexchange.com/questions/1507399/is-the-weie...

There is also

https://en.wikipedia.org/wiki/Counterexamples_in_Topology

JKCalhoun · 7 months ago
When I first learned about limits (my senior year in high school), I visualized a "step" shape graphed (0, 0) to (0, 1) and then to (1, 1). Up one unit, right one unit. (I know, not technically a function since it has a vertical component.)

But now you subdivide both segments and put in an extra step. Up 0.5, right 0.5, up 0.5, right 0.5. Same starting point, same ending point. Even the same length of line segments as before — but the area bounded beneath is 3/4 the original.

I reasoned that if you continued this subdivision, as you approach infinity the area under the "curve" approaches that of a half-unit right triangle (i.e. root-two).

How is it, I asked my math teacher, that this shape can have the perimeter of a square but the area of a triangle?

I don't recall the answer from the teacher. Maybe somewhat hand-wavy; ultimately unsatisfactory to me. I still don't really know the answer. I suppose the answer is that it is not in fact ever a triangle — just a thing with a fat edge.

fiforpg · 7 months ago
Nice example. You can avoid the issue with these being non-functions (because of the vertical segments) by rotating the picture so that the (0,0)-(1,1) diagonal is horizontal. That way you are talking about a sequence of continuous functions F_n with slopes alternating between ±1 that approach the constant-zero function F_0=0.

The reason your intuition was confused was that you felt that there was a way in which these functions with ±1 slope converge to zero function (it is called uniform convergence), but were unsure about the way in which their derivatives f_n=(F_n)' (which keep flipping between ±1) converge to zero.

The resolution of the seeming difficulty is that there are different modes of convergence. The ±1 slope functions F_n converge uniformly to zero, but their derivatives f_n, which determine curve length, do not converge uniformly or even pointwise to any limit (uniform convergence is stronger — more restrictive — than pointwise). This is why it is reasonable that the F_n curve length stays 2 throughout the exercise.

Note: if the derivatives f_n were converging to f_0=(F_0)'=0 pointwise while staying bounded, then the curve lengths of F_n would converge to sqrt(2), the curve length of F_0. This is called "dominated convergence theorem" for integrals — point being that the curve length of F_n is an integral of sqrt(1+f_n^2). But there is no pointwise convergence, and no such implication.

Finally, you may be curious as to whether there is a sense in which f_n converge to f_0=0 — does all that flipping back and forth amount to some way of converging to zero? Turns out yes! It is called weak* (weak-star) convergence and it applies to f_n if you think of them as measures (or distributions) — that is, if instead of pointwise evaluation you characterize f_n by the way they act on test functions by integration: instead of computing f_n(x) you multiply f_n * phi and integrate. Phi has to be a continuous function. Under this notion of evaluation, f_n do converge to zero.

Edit: typos.

roenxi · 7 months ago
You may be referring to the https://en.wikipedia.org/wiki/Staircase_paradox. As for how a shape can have the perimeter of a square and area of a triangle, it just can. As you've identified, it is easy to construct. It might be more interesting to ask what combinations of perimeter and area aren't possible.
madcaptenor · 7 months ago
You can always add more perimeter, so you want a lower bound on the perimeter given the area. The isoperimetric inequality (https://en.wikipedia.org/wiki/Isoperimetric_inequality) says that the smallest perimeter for a given area is that of a circle.
JKCalhoun · 7 months ago
Yes, this is what I "re-invented" (I didn't know until now that it had a name). I saw it later in a math book that I flipped through on a co-workers bookshelf (but they didn't name it there either).

Also, very cool, followed your link and they mentioned a 3D analog of sorts: https://en.wikipedia.org/wiki/Schwarz_lantern

constantcrying · 7 months ago
The perimeter (which is something very close to the derivative) is not continuous.

If you think about it a bit, you can easily change a shape in a way that greatly increases its perimeter but leaves it's area (almost) unaffected. Which means that just because two shapes are extremely close in shape, they can be very different in perimeter.

What is interesting is that it is semi continuous. The limit (this isn't quite correct) of the series is larger than the point. As the limit of the series is 2, but the actual distance is sqrt(2), which is smaller. So if you calculate the limit of the staircase perimeter you only know that it is larger or equal to the perimeter of the limit.

>I suppose the answer is that it is not in fact ever a triangle — just a thing with a fat edge.

It absolutely is a triangle. Because it converges in shape.

lordnacho · 7 months ago
The thing is, each time you do a fold, you don't get any more of the triangle's perimeter covered by the staircase.

Not only that, every point that ends up on the triangle's line segment is adjacent to a point that isn't: there's always some little epsilon that you can step along, and you are no longer on an overlapping point. You've made no difference to the perimeter.

When it comes to the area, this is not true. Folding the triangular segments over the smooth line moves an area on which you can slightly move to one side or another, and you are still in an overlap.

Gotta wonder whether the sawtooth is actually a triangle. Each step makes it... not any closer to a triangle. Why would it be a triangle when you keep going to infinity?

JKCalhoun · 7 months ago
> The thing is, each time you do a fold, you don't get any more of the triangle's perimeter covered by the staircase.

Not disagreeing with that.

> When it comes to the area, this is not true.…

Not following your point. And this part is the stickler for me: I believe the area does in fact approach the area of the triangle as the steps approach infinity.

Is this not the case as you see it?

Perhaps my "stickler" is not really one. To your first point, it's not really a triangle in the end, even as you approach infinity (though I still believe the area becomes that of said triangle). And there is nothing in geometry that says you can't have a shape with the area of a triangle but with a different perimeter.

It's just this "shape" looks an awful lot like a triangle but with a much larger perimeter.

constantcrying · 7 months ago
>Why would it be a triangle when you keep going to infinity?

Because the difference goes to zero. They are identical, they are equal in the strongest mathematical sense. The sets which make up their shape are the same set. They couldn't be more equal.

pavel_lishin · 7 months ago
3Blue1Brown actually made a video tangentially explaining this particular paradox: https://www.youtube.com/watch?v=VYQVlVoWoPY
wat10000 · 7 months ago
The answer is that the perimeter “at infinity” matches the triangle.

There’s nothing that says the perimeter of the final “infinite” shape has to equal the limit of the perimeters as they go to infinity.

In order for this to work, you have to prove that they’re equal. Typically you’d come up with two limits, one which you prove is always greater than the value in question, and one which is always less. Then you show that they’re equal in the limit. That squeezes the number you’re interested in, proving that it’s also equal to that number.

For example, the typical proof of the circumference of a circle involves making two polygons, one inside the circle and one outside. The perimeter of the one inside is always less than the circumference, and the one outside is always greater. Then you take the limit of the polygon perimeters as the number of sides goes to infinity. They converge on the same number, 2 pi r.

Deleted Comment

pif · 7 months ago
Sorry, you are completely wrong.

The perimeter is equal to the square one at every iteration, thus its limit towards infinity is still the square one.

aqme28 · 7 months ago
Reminds me of Gabriel’s Horn, which has an infinite perimeter but finite area.

Deleted Comment

praptak · 7 months ago
To me it's more interesting that every one of these curves has length 2 and yet the limit has length of sqrt(2).

(many properties are not preserved under limit but it's still somewhat interesting)

whatshisface · 7 months ago
What you're describing has a simple explanation. It's possible to fit more edge length in less space by scrunching it up.
thomassmith65 · 7 months ago
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_ · 7 months ago
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 · 7 months ago
honestly less terrible than I was expecting
praptak · 7 months ago
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 · 7 months ago
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.

synergy7 · 7 months ago
Weierstrass function is used prominently in Abbot's (2015) "Understanding Analysis" book. Abbott also relies heavily on three other mind-bending functions - Dirichlet (nowhere continuous), Thomae (discontinuous at every rational and continuous at every irrational point), and Cantor (increasing and continuous on [0, 1], yet constant at [0, 1]\C. where C is the Cantor set that is of measure zero).

Dirichlet, Thomae, and Cantor functions are central in Abbott to introduction and exercises on continuity, differentiation, and integration. I thought that was an interesting pedagogical choice for an undergraduate book, especially when it is used for the very first course in mathematical analysis as in Princeton’s MATH215 (I do think it is a really nice book).

andrewhalle · 7 months ago
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.

coke12 · 7 months ago
Are there any hierarchies in mathematics that aren't like this? It seems like most hierarchies are constructed such that going up one "level" expands your scope so much that the previous rung looks like a drop of water in the ocean.

Examples include, for example: the Chomsky hierarchy of languages, where most context-free languages are not regular; Turing computability/solvability; and so on.

waynecochran · 7 months ago
There are also functions that have a first derivate, but no second derivative. Much of my graduate research involved studying these type of functions. Many of the original ideas came from the paper "The calculus of fractal interpolation functions" https://www.sciencedirect.com/science/article/pii/0021904589... I wrote a paper on how to compute the surface normal (for rendering) of related functions: https://link.springer.com/article/10.1007/PL00013408 Interestingly enough, while you can not differentiate the Weierstrass function, you can integrate it -- i.e. you can treat it like a differential equation that has a set of well defined solutions.
awanderingmind · 7 months ago

    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.

constantcrying · 7 months ago
These examples are what caused them to be this way. Hand waving was a lot more acceptable in mathematics while Weierstrass was alive. The discovery of clear counter examples to hand waving arguments lead to the desire to put mathematics on the strong footing it is on today.

It may annoy students today as there is seemingly little utility in these distinctions, but they actually are important. The more complex mathematics becomes, the more important it is to actually be on solid footing.

madcaptenor · 7 months ago
There was definitely some of that before. Ben Franklin, in his autobiography, writes that his Junto, a group of people devoted to self-improvement, included:

"Thomas Godfrey, a self-taught mathematician, great in his way, and afterward inventor of what is now called Hadley's Quadrant. But he knew little out of his way, and was not a pleasing companion; as, like most great mathematicians I have met with, he expected universal precision in everything said, or was forever denying or distinguishing upon trifles, to the disturbance of all conversation. He soon left us."

(from Project Gutenberg's online version: https://www.gutenberg.org/files/20203/20203-h/20203-h.htm; written ~1775? about events in ~1730)

staunton · 7 months ago
It used to be less so
Sharlin · 7 months ago
Indeed, Weierstrass was one of the people thanks to whom math became the pedantic endeavor we know it as today.