Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

William Stein -- Talk for Mathematics is a long conversation: a celebration of Barry Mazur

3999 views
def prime_g(B): """ Compute the numbers g(p) for all primes p <= B, as a time series. These are the numbers g(p)=(next_prime(p)-p)/p, which are numbers between 0 and 1. """ from math import log v = [float(p) for p in prime_range(next_prime(B)+1)] # primes less than B and one more. return stats.TimeSeries([(v[i+1]-v[i])/log(v[i]) for i in range(len(v)-1)])
%time t = prime_g(10^7); t
[1.4427, 1.8205, 1.2427, 2.0556, 0.8341 ... 0.3723, 1.7372, 0.1241, 1.1168, 1.7372] CPU time: 1.13 s, Wall time: 1.13 s
%time show(t.plot_histogram(bins=1000))
CPU time: 2.16 s, Wall time: 2.10 s
show(t.plot_histogram(bins=1000),xmax=4)
%time t = prime_g(10^8); t
[1.4427, 1.8205, 1.2427, 2.0556, 0.8341 ... 0.5429, 0.9772, 0.6514, 0.9772, 0.9772] CPU time: 9.19 s, Wall time: 9.19 s
%time show(t.plot_histogram(bins=1000))
CPU time: 2.10 s, Wall time: 2.05 s
show(t.plot_histogram(bins=1000),xmax=4)
show(t.plot_histogram(bins=3000),xmax=4)
%time t = prime_g(10^9); t
[1.4427, 1.8205, 1.2427, 2.0556, 0.8341 ... 4.1499, 0.4825, 1.7372, 0.3860, 3.3778] CPU time: 91.92 s, Wall time: 91.87 s
%time show(t.plot_histogram(bins=2000))
CPU time: 6.19 s, Wall time: 6.10 s
show(t.plot_histogram(bins=4000),xmax=4)