Can anyone tell me about this pattern between $\pi(x)$ and odd square numbers up to $625$?

91 Views Asked by At

I'm just a normal "civilian" here, but a little while ago I was playing around with some numbers and noticed this little pattern that worked for $13$ numbers. I tried to google it to get more information, but I couldn't find anything, so I decided appeal to the greater interweb for insight.

So here it is: If you take the numbers $\{1, 9, 25, 49, \dots, 625\}$ (i.e. the squares of odd numbers, but ONLY up to 625) and plug them into $$f(n) =\frac{n+12\sqrt{n}-13}{8}$$ the outputs are the same as the outputs of the prime counting function, $\pi(n)$, at those values. It's not completely exact, since $f(225)$ and $f(289)$ differ from the respective $\pi(225)$ and $\pi(289)$ by $1$, but otherwise $f(n)$ gives the same values.

So I was just curious as to why this happens. Are there other numbers or algebraic formulas that coicide with $\pi(n)$ like this, or is this just coincidence?

Any insight would be appreciated. Thank you in advance for your consideration. Have a wonderful day!

2

There are 2 best solutions below

0
On

There are other numbers and formulas which do approximate $\pi(x)$. Note that $\pi(x)$ is very well approximated by $\frac{x}{\ln x}$. What is happening with your formula is I think essentially a coincidence. Your formula will break down badly when $n$ is large as your formula will give values much, much bigger than $\pi(x)$. For example, $\pi(10^6)$ is about 78,000, and your formula will predict around 120,000. In general, there are a lot of formulas which are easy to write down that only work for small values of $n$.

1
On

This is more comment than answer, in part because there are a number of directions in which one could take the OP's question, and it's hard to tell which direction (if any) would be most productive.

The OP has, in effect, made the following observation:

Let $P(n)=(2n+1)^2$ and $Q(n)=n(n+7)/2$, let $k=1$, and let $N=12$. Then

$$|\pi(P(n))-Q(n)|\le k$$

for $0\le n\le N$. Moreover, $\pi(P(n))=Q(n)$ for all but $2$ of the values of $n$ in the interval $[0,N]$.

What's remarkable is that for two relatively simple polynomials, we have such good agreement between $\pi(P(n))$ and $Q(n)$ for so many values of $n$. This is a little like the famous observation that $n^2+n+41$ is prime for $0\le n\le39$.

Since $\pi(P(n))\approx P(n)/\ln(P(n))$ for large $n$, it's easy to show that $|\pi(P(n))-Q(n)|\to\infty$ as $n\to\infty$, so no close agreement can persist, and this will be true for all polynomials $P$ and $Q$ and all proximity bounds $k$. It's likely true that $n=12$ is the last value that works for the OP's observation (i.e., $n(n+7)/2\gt\pi((2n+1)^2)+1$ for all $n\gt12$), but it might be a bit tricky to prove it (that is, you can't just cite the Prime Number Theorem).

Given any polynomial $P$ and any $N$, it's clear you can find an interpolating polynomial $Q$ of degree at most $N$ such that $\pi(P(n))=Q(n)$ for $0\le n\le N$. Relaxing the condition to $|\pi(P(n))-Q(n)|\le k$ means the degree of $Q$ and/or its coefficients might be considerably reduced. The question is, how considerably? It might be worth playing around with a few other quadratic (or even linear) polynomials $P$ and see if some suitably large initial batch of values of $\pi(P(n))$ can be nicely approximated by some other polynomial $Q$ of small degree.