File:Comparison of prime-counting approximations.svg
Summary
| Description |
English: Plot comparing three functions related to the distribution of prime number: the prime-counting function π(x), the logarithmic integral Li(x), and the aproximation x/log(x).
Português: Gráfico comparando três funções relacionadas à distribuição de números primos: a função de contagem de números primos π(x), a integral logarítmica Li(x), e a aproximação x/log(x). |
| Date | |
| Source |
Own work Category:Unspec SVG created with Matplotlib#00041122Comparison%20of%20prime-counting%20approximations.svg |
| Author | Vickvvy |
Matplotlib (Python)
# Author: Vickvvy, 2025-05-19
import matplotlib.pyplot as plt
from sympy import primepi
from scipy.integrate import quad
import numpy as np
def xlogx(x):
return x / np.log(x)
def Li_array(x_array):
return np.array([quad(lambda t: 1 / np.log(t), 2, xi)[0] for xi in x_array])
x = np.linspace(2.01, 10000, 500000)
y1 = xlogx(x)
y2 = Li_array(x)
y3 = [primepi(int(xi)) for xi in x]
plt.figure(figsize=(10, 6))
plt.plot(x, y1, label=r"$\frac{x}{\log x}$", color='red')
plt.plot(x, y2, label=r"$\mathrm{Li}(x)$", color='blue')
plt.plot(x, y3, label=r"$\pi(x)$", color='green')
plt.legend()
plt.xlabel("x")
plt.ylabel("y")
plt.grid(True)
plt.savefig("pi_li_xlogx.svg", format='svg')
plt.show()
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.