def test_zetazero():
    cases = [\
    (399999999, 156762524.6750591511),
    (241389216, 97490234.2276711795),
    (526196239, 202950727.691229534),
    (542964976, 209039046.578535272),
    (1048449112, 388858885.231056486),
    (1048449113, 388858885.384337406),
    (1048449114, 388858886.002285122),
    (1048449115, 388858886.00239369),
    (1048449116, 388858886.690745053)
    ]
    for n, v in cases:
        print(n, v)
        t1 = clock()
        ok = zetazero(n).ae(complex(0.5, v))
        t2 = clock()
        print("ok =", ok, ("(time = %s)" % round(t2 - t1, 3)))
    print("Now computing two huge zeros (this may take hours)")
    print("Computing zetazero(8637740722917)")
    ok = zetazero(8637740722917).ae(complex(0.5, 2124447368584.39296466152))
    print("ok =", ok)
    ok = zetazero(8637740722918).ae(complex(0.5, 2124447368584.39298170604))
    print("ok =", ok)
Пример #2
0
def test_zetazero():
    cases = [\
    (399999999, 156762524.6750591511),
    (241389216, 97490234.2276711795),
    (526196239, 202950727.691229534),
    (542964976, 209039046.578535272),
    (1048449112, 388858885.231056486),
    (1048449113, 388858885.384337406),
    (1048449114, 388858886.002285122),
    (1048449115, 388858886.00239369),
    (1048449116, 388858886.690745053)
    ]
    for n, v in cases:
        print n, v,
        t1 = clock()
        ok = zetazero(n).ae(complex(0.5,v))
        t2 = clock()
        print "ok =", ok, ("(time = %s)" % round(t2-t1,3))
    print "Now computing two huge zeros (this may take hours)"
    print "Computing zetazero(8637740722917)"
    ok = zetazero(8637740722917).ae(complex(0.5,2124447368584.39296466152))
    print "ok =", ok
    ok = zetazero(8637740722918).ae(complex(0.5,2124447368584.39298170604))
    print "ok =", ok
Пример #3
0
def calc_zeta(re, img_name):
    X, Y, Z = [], [], []

    fig = plt.figure()
    ax = fig.add_subplot(111)

    for i in np.arange(0.1, 50.0, 0.1):
        compl = zeta(complex(re, i))
        X.append(compl.real)
        Y.append(compl.imag)
        Z.append(i)

    ax.grid(True)
    ax.plot(Z, X, label='Im(v)', lw=0.8)
    ax.plot(Z, Y, label='Re(v)', lw=0.8)
    ax.set_title("Riemann Zeta function - re(s)=%.3f" % re)
    ax.set_xlabel("Im(s)")
    ax.set_ylabel("Re(v) and Im(v)")

    leg = ax.legend(shadow=True)
    for t in leg.get_texts():
        t.set_fontsize('small')

    for l in leg.get_lines():
        l.set_linewidth(2.0)

    # Plot the zeroes of zeta
    for i in range(1, 11):
        zero = zetazero(i)
        ax.plot(zero.imag, [0.0], "ro")

    # Comment this line for autoscale
    ax.set_ylim(12, -12)
    plt.savefig(img_name)
    print("Plot %s !" % img_name)
    plt.close()
Пример #4
0
def getNthZetaZero( n ):
    return zetazero( int( n ) )
Пример #5
0
imag = []

for k in t:
    real.append(zeta(complex(0.5, k)).real)
    imag.append(zeta(complex(0.5, k)).imag)

fig_size = plt.rcParams["figure.figsize"]
fig_size[0] = 13
fig_size[1] = 6
plt.rcParams["figure.figsize"] = fig_size

plt.axhline(0, color='black', linewidth=1)
plt.axvline(0, color='black', linewidth=1)

for k in [1,2]:
    zero = zetazero(k).imag
    plt.axvline(zero, color='grey', alpha=1, linewidth=1, linestyle='dashed')
    plt.axvline(zero*(-1), color='grey', alpha=1, linewidth=1, linestyle='dashed')

plt.plot(t, real, color='blue', linewidth=3, label=r'$\operatorname{Re}\left(\zeta\left(\frac{1}{2} + i t\right)\right)$')

plt.plot(t, imag, color='red', linewidth=3, label=r'$\operatorname{Im}\left(\zeta\left(\frac{1}{2} + i t\right)\right)$')

plt.xlim(-24,24)
plt.ylim(-3,3)
plt.xlabel("t")
plt.ylabel(r"$\zeta\left(\frac{1}{2} + i t\right)$")
plt.legend(loc='best')
plt.grid(True)

pylab.savefig("critical-line.pdf")
Пример #6
0
# zeta-zeroes-info.py zeichnet eine komplexe Zahlenebene, in der
# die Nullstellen der Zetafunktion dargestellt werden.

fix, ax = plt.subplots()

re_trivial = []
im_trivial = []
re_nontrivial = []
im_nontrivial = []

for k in range(0, 2):
    re_trivial.append(-2 * (k + 1))
    im_trivial.append(0)

for j in range(0, 6):
    re_nontrivial.append(zetazero(j + 1).real)
    im_nontrivial.append(zetazero(j + 1).imag)
    re_nontrivial.append(zetazero(j + 1).real)
    im_nontrivial.append(-zetazero(j + 1).imag)

plt.axhline(0, color='black', alpha=1, linewidth=1)
plt.axvline(0, color='black', alpha=1, linewidth=1)
plt.axvline(0.5,
            color='black',
            alpha=1,
            linewidth=1,
            linestyle='dashed',
            label=r'Kritische Gerade $\operatorname{Re}(s)=\frac{1}{2}$')
ax.add_patch(
    patches.Rectangle(
        (0, -40),
The main objective of plotting RZ function is to verify is all the non-trivial
zeros of RZ function has the real part of 0.5. The locations of non-trivial
zeros are the locations of the prime numbers. Hence, this plot plots the
distribution of prime numbers on the imaginary numberspace.

"""

import matplotlib.pyplot as plt
import mpmath

n = int(raw_input("Input total number of Reimann Zeros to chart [default = 25]") or 25)

listx, r, im, counter = [], [], [], []

for i in range (1,n):
    x = mpmath.zetazero(i)
    listx.append(x)
    ri = x.real
    imi = x.imag
    r.append(ri)
    im.append(imi)
    counter.append(i)
    
zet = plt.figure()
zetx = zet.add_subplot(111)
zetx.scatter(r, im, lw = 2, marker = "+")
zetx.set_xlim([-1, 1])
zetx.grid(True)
plt.title("Distribution of Prime Numbers on Riemann Zeta's critical strip.")
plt.show()