-
Notifications
You must be signed in to change notification settings - Fork 0
/
plots.py
82 lines (72 loc) · 3.52 KB
/
plots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Implementation of various plots
import numpy as np
import primes
import matplotlib.pyplot as plt
from matplotlib.ticker import (MultipleLocator, AutoMinorLocator)
# vectorize functions that are referred to in plots
Pi = np.vectorize(primes.Pi)
RiemannPi = np.vectorize(primes.RiemannPi)
Ck = np.vectorize(primes.Ck)
def plotCk(k): # plots Ck(i)
x = np.linspace(2, 100, 3000)
c = Ck(x, k)
plt.plot(x, c, 'b')
plt.show()
def plotPrimeCount(n = 0): # prime numbers plot, with N being number of zeta zeros to include in R(x) correction
xp = np.linspace(0, 100, 10000)
p = Pi(xp)
x = np.linspace(1, 100, 1920)
y = RiemannPi(x, n)
px = 1 / plt.rcParams['figure.dpi']
figure, axis = plt.subplots(2, 1, figsize=(1920*px, 1080*px))
figure.suptitle(r"Approximation of prime counting function $\pi(x)$ by Riemann's R(x)", fontsize=14)
plt.subplots_adjust(left=0.06, right=0.94, top=0.93, bottom=0.05, wspace=0.07, hspace=0.15)
axis[0].plot(xp, p, color='#dd0000', label=r'$\pi(x)$', linewidth=2)
axis[0].plot(x, y, color='#009900', label='R(x)', linewidth=2)
axis[0].set_label('x')
axis[0].set_label('y')
axis[0].set_title("0 < x < 100")
axis[0].set_xlim([0, 100])
axis[0].set_ylim([0, 26])
axis[0].xaxis.set_major_locator(MultipleLocator(10))
axis[0].xaxis.set_major_formatter('{x:.0f}')
axis[0].xaxis.set_minor_locator(MultipleLocator(1))
axis[0].yaxis.set_minor_locator(MultipleLocator(1))
axis[0].legend(loc='lower right')
axis[1].plot(xp, p, color='#dd0000', label=r'$\pi(x)$', linewidth=2)
axis[1].plot(x, y, color='#009900', label='R(x)', linewidth=2)
axis[1].set_label('x')
axis[1].set_label('y')
axis[1].set_title("0 < x < 20")
axis[1].set_xlim([0, 20])
axis[1].set_ylim([0, 8.5])
axis[1].xaxis.set_major_locator(MultipleLocator(5))
axis[1].xaxis.set_major_formatter('{x:.0f}')
axis[1].xaxis.set_minor_locator(MultipleLocator(1))
axis[1].legend(loc='lower right')
figure.text(0.063, 0.909, str(n) + r" non-trivial $\zeta$ zero pairs", fontsize=16, color = "#009900")
figure.text(0.063, 0.437, str(n) + r" non-trivial $\zeta$ zero pairs", fontsize=16, color = "#009900")
figure.text(0.06, 0.01, "Formulas optimized for computing based on: [1] 'Prime numbers and computer methods for factorization', Hans Riesel, 1994" +
" [2] 'Some calculations related to Riemann's prime number formula', Hans Riesel, 1970", fontsize=10)
figure.text(0.97, 0.98, r"ac, 2023", fontsize=8)
return plt
def plotSinglePrimeCount(x, yarr, n = 0): # prime numbers single plot (no zoom), with N being number of zeta zeros to include in R(x) correction
xp = np.linspace(0, 100, 10000)
p = Pi(xp)
px = 1 / plt.rcParams['figure.dpi']
figure, axis = plt.subplots(1, 1, figsize=(1080*px, 1920*px))
figure.suptitle(r"Approximation of prime counting function $\pi(x)$ by Riemann's R(x)")
axis.plot(xp, p, 'r', label=r'$\pi(x)$', linewidth=2)
axis.plot(x, yarr[n], 'g', label='R(x)', linewidth=2)
axis.set_label('x')
axis.set_label('y')
axis.set_title("0 < x < 100")
axis.set_xlim([0, 100])
axis.set_ylim([0, 26])
axis.xaxis.set_major_locator(MultipleLocator(10))
axis.xaxis.set_major_formatter('{x:.0f}')
axis.xaxis.set_minor_locator(MultipleLocator(1))
axis.yaxis.set_minor_locator(MultipleLocator(1))
axis.legend(loc='lower right')
figure.text(0.15, 0.83, str(n) + r" non-trivial $\zeta(x)$ zero pairs", fontsize=16)
return plt