Okay, so I decided to dive into this Mertens prediction thing I’d heard about. Wasn’t entirely sure what it was, but sounded interesting enough to poke around with.

Getting Started
First thing, I needed to understand the basics. It revolves around something called the Möbius function. This function looks at the prime factors of a number. If a number has a squared prime factor (like 4, 8, 9, 12), the function is zero. If it has an even number of distinct prime factors (like 6 = 23), it’s 1. If it has an odd number of distinct prime factors (like 30 = 235), it’s -1. And for the number 1, it’s just 1.
So, step one was figuring out how to calculate this Möbius function for any given number. I needed a way to find prime factors. I dusted off some old code I had for prime factorization. Nothing fancy, just trial division works okay for smaller numbers.
Building the Mertens Function
Once I could get the Möbius value for a single number, the Mertens function, usually called M(n), is just the sum of all the Möbius values from 1 up to n. So, M(1) = μ(1), M(2) = μ(1) + μ(2), M(3) = μ(1) + μ(2) + μ(3), and so on. μ is the common symbol for the Möbius function.
I wrote a simple loop. It went from 1 up to some limit N I set.
- Inside the loop, for each number i:
- Calculate its Möbius value, μ(i).
- Add this value to a running total.
- Store this running total as M(i).
I started with a small N, maybe 100, just to see if it worked without crashing or giving crazy results. Seemed okay. The values bounced between positive and negative numbers, but stayed pretty small.
Pushing the Limits and Plotting
The real curiosity was about the “prediction” part. The idea, or conjecture really, is that the Mertens function doesn’t grow too large. Specifically, it’s thought that its absolute value is always less than the square root of n. That sounded like something you could check, at least visually.
So, I increased N. Went up to 1,000, then 10,000, then tried for 100,000. It started getting noticeably slower. Calculating prime factors for every single number takes time, especially as the numbers get bigger. There are probably smarter ways, like sieving or pre-calculating primes, but I just stuck with the straightforward approach for this first attempt.
With the data points (n, M(n)) collected, I needed to see the shape. I dumped the results into a simple file and used a basic plotting tool I have lying around. Just plotted M(n) on the y-axis against n on the x-axis.

I also plotted the bounds: sqrt(n) and -sqrt(n). This was the interesting part.
Observations
Looking at the plot, the Mertens function M(n) does indeed wiggle around zero. It goes up, it goes down. For the range I calculated (up to where my patience ran out with the slow computation), it stayed well within the square root boundaries. It never even got close, really.
It’s quite fascinating to see it visually. You calculate all these +1s, -1s, and 0s based on prime factors, sum them up, and the total sum seems weirdly constrained. It doesn’t just shoot off to infinity or oscillate wildly; it stays relatively tame, hugging the zero line compared to the sqrt(n) curves.
Of course, my little experiment doesn’t prove the conjecture. People have checked this for vastly larger numbers using serious computing power. Apparently, the conjecture is actually false, but the counterexample is expected to be enormous, way beyond anything I could compute easily.
Still, it was a good exercise. Went from knowing almost nothing about the Mertens function to getting my hands dirty, writing some code, calculating the values, and seeing the pattern (or lack of wild growth) for myself up to a certain point. Felt like a productive afternoon messing with numbers.