I’ve been thinking about this for days. Incredible stochastic algorithm, gets more reliable the larger your input, incredibly fast, trivial to implement and deterministic on its inputs. It really has so much going for it.

(Via @jonathankoren )

@mhoye @jonathankoren And no false positives!
@mhoye @sellout @jonathankoren
It's accuracy asymptotically approaches 100%
That's amazing!
Slight cavities about using it for cryptographic purposes or around smallish numbers.
@mhoye @jonathankoren wow, so much more efficient than the state-of-the-art algorithm: asking a LLM whether x is prime
@jonathankoren @mhoye they’re all good algorithms, Brent
@adardis @mhoye there are no bad algorithms. There are only bad use cases.
@jonathankoren @adardis @mhoye this is like that weather aphorism, isn't it
@jonathankoren Is there a use case for Bogosort?
@mhoye @jonathankoren it's branchless too, and easily parallelized onto a GPU to speed it up
@mhoye @jonathankoren @daedalus I hope the crypto crew catch wind of this. Has potential to save a lot of electricity
@mhoye @jonathankoren @rmondello Surprising fact: exactly the same algorithm works even better for many other problems: perfect numbers, powers of two, busy beaver, etc.

@jonathankoren @mhoye

The problem is its inaccuracy for smaller input sets involving low-digit-count numbers.

Trivially fixed by hardcoding the results for 3-digit and lower input. Ship it!

@mhoye @jonathankoren It also provides the script for a math party trick: "Tell me any 100 digit number and I will tell you if it's prime!'
@mhoye @jonathankoren are you sure about the more reliable the larger input? Prime number are weird
@mhoye Algorithms like this are used as a pre-prime testing before you do the actual prime testing that requires CPU heavy computation.
@mhoye
@jonathankoren
It is one of the best one-class classifier I've ever seen. Extremely efficient and the computational time doesn't grow the larger the input gets.
@mhoye @silicatefondue @jonathankoren this class of algorithm is called the stopped clock algorithm. It joins the previously identified Monte Carlo and las Vegas algorithms.
@mhoye @jonathankoren amazing, we've discovered prime numbers past 2
@mjdxp @jonathankoren This changes everything!
@mhoye @jonathankoren can absolutely relate. Constantly trying convince my quantitative colleagues that discrete maths is different from their stochastic and AI based reasoning.

@mhoye @jonathankoren

Reminds me of another ...

float sin(float x) { return x; }

is remarkably accurate for a large proportion of the possible input values.

@TheLancashireman @mhoye @jonathankoren physicists bread and butter. "x is small, so sin(x) is roughly x"
@mhoye @jonathankoren The best part is that the apparent errors are just an artifact of the test methodology. The stricter you make your test, the more accurate the algorithm measures.

@mhoye
@jonathankoren

It has 100% Test Coverage, too!

This means, it has no bugs, right?

@mhoye @jonathankoren

similarly 7 9s chance of undefined behavior in C++ integer multiplication due to overflow. so probable with random Input that optimizing away imul operations would be done by an AI-based optimizer