Today I came across this formula, and I noticed it was pretty close to the number of prime less than or equal to $n$:
$$ \pi\left(n\right)\approx\frac{2}{5}(\sqrt[5]{2})n^{\frac{4}{5}}+\frac{n}{20}$$
In fact it is so close that from $1<n<10000$, the largest error is $5$, and for $n<1000000$:
$$\left|\pi\left(n\right)-\left(\frac{2}{5}\sqrt[5]{2}n^{\frac{4}{5}}+\frac{n}{20}\right)\right|<46$$
After that, the difference starts to grow quickly, so I guess we would need to add a term $\pm\frac{n}{x}$ at the end ?
How is it possible to get an approximation that good with a formula that simple? But more importantly, how to find the next terms in the asymptotic expansion ? (if that's what it is)
$n^{\frac 45}$ is too small as the prime number theorem shows. It is much less than $\frac n{\log n}$. You can get a decent fit over a small range by choosing the constants. For $n=10^{15}, n^{\frac 45}=10^{12}=\frac n{1000}$, while $\log (10^{15})\approx 34.5$ A term like $\frac nx$ will not help-it is just a change to the $\frac 1{20}$ coefficient you already have. On the other hand, $\frac n{20}$ is much too large. Once $n \gt e^{20} \approx 5 \cdot 10^8$, it alone is too large. When you talk of things like counting prime numbers, you need much larger ranges to be impressed by a close fit.