File:Comparison of prime-counting approximations.svg

Uploaded by Vickvvy
Upload date 2025-05-19T18:06:50Z
MIME type image/svg+xml
Dimensions 960 × 576 px
File size 72.2 KB

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
 This W3C-unspecified plot was created with Matplotlib.
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:
w:en:Creative Commons
attribution share alike
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.

Captions

Plot comparing three functions related to the distribution of prime number.

Items portrayed in this file

depicts

19 May 2025

73,905 byte

image/svg+xml

147b35bdbe5fdcea0532a3d3326dfb88f9c23849

Category:CC-BY-SA-4.0 Category:Prime Pi function Category:Self-published work Category:Unspec SVG created with Matplotlib