Research Article - (2026) Volume 1, Issue 1
A Modified Formula of Function Li (X) For Prime Number Counting
Received Date: Nov 06, 2025 / Accepted Date: Jan 30, 2026 / Published Date: Mar 02, 2026
Copyright: ©2026 Zhi Li, et al. This is an open-access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.
Citation: Li, Z., Li, H. (2026). A Modified Formula of Function Li (X) For Prime Number Counting. J Quant Sci Emerging Technol, 1(1), 01-08
Abstract
To calculate the number of prime numbers, the prime number theorem function x/ln (x) and Gaussian function Li (x) are most commonly used. However, the former is always less than and the latter is always greater than the actual number of prime numbers, and the deviation increases with the increase of the order of magnitude. The function p (x) has been proposed to improve x/ln (x). Now the Gaussian function Li (x) is dynamically modified, and a more ideal prime number estimation function q (x) is obtained. Numerical experiments show that the modified q (x) calculation is simple and accurate compared with the calculation results of p (x) and Riemann function R (x).
Keywords
Prime Number Theorem, Number of Prime Numbers, Prime Number Counting Function, Dynamic Correction
Introduction
To calculate the number of prime numbers, the prime number theorem function x/ln (x) and Gaussian function Li (x) are most commonly used [1]. The Gaussian function Li (x) is expressed as [2]:


where: ζ(n) is Riemann ζ function.
The calculation of Riemann function is complicated, and it deviates from the true value as Li(x) when the given order of magnitude is very large [4]. Therefore, it is necessary to explore more accurate prime number counting function.
The distribution type of prime numbers belongs to deterministic random distribution [5]. Therefore, theoretically, there is a function that can relatively accurately represent the number of prime numbers.
Now, the Gaussian function Li (x) is dynamically modified to arrive at a more ideal prime number estimation formula q (x). Numerical experiments show that the modified q (x) is simpler and more accurate than p (x) and R (x) .
The Number of Prime Numbers Less Than the Given Order of Magnitude
The experimental observation shows that the deviation of calculated-value of Gaussian function Li (x) is large and always greater than the actual prime number count. In this paper, Gaussian function Li (x) is dynamically modified, and an appropriate positive function is added to the denominator of its integral formula to reduce the value of the integral and make it closer to the actual prime number count. After a lot of experiments and further optimization, the function expression is determined and the following definition is given.
Define q (x) as the modified prime count function:


Experimental Verification
Use q (x) to calculate the number of prime numbers smaller than the given number order, and compare with the calculation results of p (x) and R (x). See Table 1 to Table 2 and Figure 1 to Figure 9 for details. The experiment shows that in many cases, q (x) and p (x) and R (x) are very close to the prime number counting function π (x), and with the increase of x, q (x) and p (x) and R (x) and π (x) cross each other, and q (x) shows good approximation performance. The function q (x) is simple in form, convenient in calculation and relatively high in accuracy.
|
x |
π(x) |
p(x) |
R(x) |
q(x) |
p(x)/π(x) |
R(x)/π(x) |
q(x)/π(x) |
(p(x)-π(x)) /π(x) |
(R(x)-π(x)) /π(x) |
(q(x)-π(x)) /π(x) |
|
10^1 |
4 |
9 |
5 |
5 |
2.2500 |
1.2500 |
1.2500 |
1.2500 |
0.2500 |
0.2500 |
|
10^2 |
25 |
29 |
26 |
26 |
1.1600 |
1.0400 |
1.0400 |
0.1600 |
0.0400 |
0.0400 |
|
10^3 |
168 |
172 |
168 |
170 |
1.0238 |
1.0000 |
1.0119 |
0.0238 |
0.0000 |
0.0119 |
|
10^4 |
1229 |
1230 |
1227 |
1229 |
1.0008 |
0.9984 |
1.0000 |
0.0008 |
-0.0016 |
0.0000 |
|
10^5 |
9592 |
9578 |
9587 |
9588 |
0.9985 |
0.9995 |
0.9996 |
-0.0015 |
-0.0005 |
-0.0004 |
|
10^6 |
78498 |
78459 |
78527 |
78516 |
0.9995 |
1.0004 |
1.0002 |
-0.0005 |
0.0004 |
0.0002 |
|
10^7 |
664579 |
664472 |
664667 |
664605 |
0.9998 |
1.0001 |
1.0000 |
-0.0002 |
0.0001 |
0.0000 |
Table 1: Calculation and Comparison of the Number of Prime Numbers Less Than the Given Magnitude
Note: x is an integer, π (x) is the actual number function of prime numbers, p (x) is the improved prime number counting function, R (x) is the Riemann prime number counting function, and q (x) is the modified prime number counting function in this paper.
|
x |
π(x) |
p(x) |
R(x) |
q(x) |
(p(x)-π(x)) /π(x) |
(R(x)-π(x)) /π(x) |
(q(x)-π(x)) /π(x) |
|
[10000,10200] |
23 |
21.5365 |
21.5658 |
21.5666 |
-0.0635 |
-0.0622 |
-0.0623 |
|
[20000,20200] |
22 |
20.0734 |
20.1033 |
20.1003 |
-0.0877 |
-0.0864 |
-0.0864 |
|
[30000,30200] |
21 |
19.3023 |
19.3310 |
19.3271 |
-0.0810 |
-0.0795 |
-0.0797 |
|
[40000,40200] |
20 |
18.7889 |
18.8164 |
18.8121 |
-0.0605 |
-0.0590 |
-0.0594 |
|
[50000,50200] |
20 |
18.4086 |
18.4349 |
18.4306 |
-0.0795 |
-0.0785 |
-0.0785 |
|
[60000,60200] |
19 |
18.1088 |
18.1342 |
18.1298 |
-0.0468 |
-0.0458 |
-0.0458 |
|
[70000,70200] |
22 |
17.8627 |
17.8871 |
17.8828 |
-0.1882 |
-0.1868 |
-0.1484 |
|
[80000,80200] |
15 |
17.6547 |
17.6784 |
17.6741 |
0.1767 |
0.1787 |
0.1783 |
|
[90000,90200] |
23 |
17.4752 |
17.4981 |
17.4939 |
-0.2400 |
-0.2391 |
-0.2048 |
|
[100000,100200] |
15 |
17.3175 |
17.3399 |
17.3357 |
0.1547 |
0.1560 |
0.1557 |
|
[200000,200200] |
17 |
16.3465 |
16.3646 |
16.3610 |
-0.0382 |
-0.0376 |
-0.0376 |
|
[300000,300200] |
15 |
15.8267 |
15.8423 |
15.8391 |
0.0553 |
0.0560 |
0.0559 |
|
[400000,400200] |
14 |
15.4773 |
15.4912 |
15.4883 |
0.1057 |
0.1064 |
0.1063 |
|
[500000,500200] |
16 |
15.2166 |
15.2293 |
15.2266 |
-0.0488 |
-0.0481 |
-0.0483 |
|
[600000,600200] |
10 |
15.0100 |
15.0217 |
15.0191 |
0.5010 |
0.5020 |
0.5019 |
|
[700000,700200] |
14 |
14.8395 |
14.8504 |
14.8480 |
0.0593 |
0.0607 |
0.0606 |
|
[800000,800200] |
16 |
14.6951 |
14.7052 |
14.7029 |
-0.0813 |
-0.0806 |
-0.0811 |
|
[900000,900200] |
16 |
14.5698 |
14.5794 |
14.5772 |
-0.0894 |
-0.0888 |
-0.0889 |
|
[1000000,1000200] |
16 |
14.4596 |
14.4686 |
14.4665 |
-0.0900 |
-0.0956 |
-0.0958 |
|
Total deviation |
|
|
|
|
2.2475 |
2.2479 |
2.1757 |
|
average deviation |
|
|
|
|
0.11829 |
0.11831 |
0.11451 |
|
maximum deviation |
|
|
|
|
0.5010 |
0.5020 |
0.5019 |
Table 2: Calculation and Comparison of the Number of Prime numbers within a Given Integer Interval
|
interval range x |
q(x) |
R(x) |
||||
|
maximum deviation absolute value |
average deviation absolute value |
standard deviation |
maximum deviation absolute value |
average deviation absolute value |
standard deviation |
|
|
[1,1000] |
3.4268 |
1.2878 |
0.7667 |
2.0294 |
0.5706 |
0.4310 |
|
[10000,11000] |
3.7922 |
1.1069 |
0.7897 |
6.1107 |
2.1816 |
1.2874 |
|
[50000,51000] |
6.6674 |
2.3664 |
1.9654 |
5.0441 |
1.8486 |
1.3319 |
Table 3:Comparison of Deviations of q (x) and R(x) in Calculating the Number of Prime Numbers in Given Intervals

Figure 2: Brown Li (x), Green q (x), Red p (x), Blueπ(x), Black R (x), Purple x/ln (x)

Figure 4: Green q (x), Red p (x), Blueπ(x), Black R (x)

Figure 6: Green q (x), Red p (x), Blueπ(x), Black R (x)

Figure 8: Green q (x), Red p (x), Blueπ(x), Black R (x)

Discussion & Conclusion
Table 1 shows that using q (x) to calculate the number of prime numbers smaller than the given number order is relatively accurate, which is better than using p (x) and R (x).
Table 2 shows that there are 19 groups of data for q (x), p (x) and R (x) in a given interval. Comparing the calculated values of q (x) and p (x) and R (x) with the calculated values of π (x), the variation direction of q (x) and p (x) and R (x) is completely consistent, and the synchronization rate reaches 100.00%; 6 groups and 13 groups (31.58% and 68.42%) are more than and less than the calculated value of π (x); among them, 7 groups of q (x) are superior to R (x), accounting for 36.84%; q (x) is superior to p (x) in 14 groups, accounting for 73.68%.
The calculated results of q (x) are similar to those of p (x) and R (x), but the maximum deviation and average deviation are slightly better than R (x).
As can be seen from the results in Table 3, there are three groups of data for q(x) and R(x) in a given interval. Among them, there is one group where the the deviation calculated by q(x) is better than that by R(x). The maximum deviation, average deviation and standard deviation in the three groups of data are relatively small. Figure 1 shows the relationship between the six functions on the interval [10, 1000]. Li (x) is always greater than, x/ln (x) is always less than p (x), q (x), π (x), and R (x); and q (x), π (x) and R (x) are intertwined. The results in Figures 2 to 9 show that the function curve of q (x) and p (x) and R (x) and the function curve of π (x) are entangled and crossed in many places, indicating that when calculating the number of prime numbers in different intervals, there will be a situation where q (x) and p (x) and R (x) are alternately optimal. In addition, the function curves of q (x) and p (x), π (x) and R (x) are very close and fit well. In Figure 4 and after, due to the large deviation of x/ln (x), it no longer appears in the figure.
Because of the randomness of the distribution of prime numbers, the actual number of prime numbers always fluctuates above and below the value of the function q (x) , changing frequently and presenting a fluctuating state. Therefore, the function curve of q (x) can be called prime number curve, and q (x) can be called prime number counting function and it is easy to know that the calculation of q (x) is simple and the accuracy is higher than that of p (x) and R (x). The function q (x) is an ideal prime number counting function and may have a wide application prospect.
References
- Hardy, G. H., & Wright, E. M. (2008). An introduction to the theory of numbers. Oxford university press.
- https://mathworld.wolfram.com/PrimeCountingFunction. html
- Li, Z., & Li, H. A Revised Prime Number Counting Function.
- https://primes.utm.edu/howmany.html
- Li, Z., & Li, H. Proof of N^2+1 Conjecture.

