On 16/01/2026 17:26, Yasser A. Chavez wrote:
> I was writing a pedagogical text about the Sieve of Eratosthenes and
> the prime-counting function, but I did not want to use the classic
> formulas. What began as a search for a modest formula for practical
> purposes led me to realize that, instead of subtracting the sequences,
> I had to sum them and, by multiplying by an adjustment factor, I could
> approximate the prime-counting function with a minimal margin of error.
>
> The sequences involved are the tetrahedral numbers and the "maximum
> number of pieces obtained by slicing a torus (or a bagel) with n
> cuts", given by the formula (n^3 + 3*n^2 + 8*n)/6 for n > 0.
>
> Endless thanks to N. J. A. Sloane and Mira Bernstein for making my
> text much more interesting.
>
> I share the data for the interval 10^4 < π(n) < 2*10^5:
>
> (k/50)*(A000292(n) + A003600(n-1)) ≈ π(A000292(n))
The thing you've called k doesn't seem to be constant -- you're putting
in a different value in every calculation below.
But if it doesn't have to be constant, you could just _define_ k = 50
pi(A000292(n)) / (A000292(n) + A003600(n-1)) and get _exact_ agreement!
And this would work no matter what the actual sequences were, so the
formula doesn't really tell you anything about the relationship between
those sequences and the prime-counting function.
Now, one thing that _isn't_ completely automatic is that over the range
of values you looked at, k doesn't change very much. But that's largely
because the required value changes slowly and the range you've looked at
is quite small. Suppose we take n = 1000. Then:
A000292(n) = 167167000
A003600(n-1) = 166667499
pi(A000292(n)) = 9353402
and so the value of k you need to make things work out is 50 x 9353402 /
(167167000 + 166667499) ~= 1.4. That's quite a lot smaller than the
values in your calculations. For larger n it will continue to decrease.
More generally, for large n the values of those two sequences are both
approximately n^3/6; call this N; then your formula says pi(N) ~=
k/25.N; what actually happens for large N is pi(N) ~= N/log(N), so the
value of k you need is about 25/log(N). In fact a slightly better
approximation is pi(N) ~= N/(log(N)-1) so better to take k = 25/(log(N)-1).
(note: these are _natural_ logarithms, not base-10 ones)
So e.g. when N=10^5 (where your examples suggest k ~= 2.43) we have
log(N) ~= 11.5, so 25/(log(N)-1) ~= 2.38; the agreement isn't perfect
but N is still fairly small here. When n=1000 and so N ~= 10^9/6, we
have 25/(log(N)-1) ~= 1.39 versus the 1.4 I found above.
So you could, if you wanted, replace "k" with "25/(log(A000292(n))-1)"
in your formula and get something that's approximately true for all n,
and gets better as n gets larger. But the only facts about A000292 and
A003600 that this would be relying on are (1) they get large for large n
and (2) for large n they are (relatively) very close to one another.
--
g