Prime Numbers

Euler's Formula and Littlewood's Theorem

Euler's Formula

euler[n_]:=(n^2)+n+41

euler[1]
euler[2]
euler[3]
euler[4]
euler[5]

euler[6]
PrimeQ[euler[6]]

euler[7]
PrimeQ[euler[7]]

euler[8]
PrimeQ[euler[8]]

euler[9]
PrimeQ[euler[9]]

euler[10]
PrimeQ[euler[10]]

euler[11]
PrimeQ[euler[11]]

euler[12]
PrimeQ[euler[12]]

euler[13]
PrimeQ[euler[13]]

euler[14]
PrimeQ[euler[14]]

euler[15]
PrimeQ[euler[15]]

euler[16]
PrimeQ[euler[16]]

euler[17]
PrimeQ[euler[17]]

euler[18]
PrimeQ[euler[18]]

euler[19]
PrimeQ[euler[19]]

euler[20]
PrimeQ[euler[20]]

Littlewood's Theorem

The built in Mathematica function Prime[n] computes the nth prime number, whereas the function PrimePi[n] computes the number of primes less than or equal to n.  For example:  
	PrimePi[2]=1
	PrimePi[3]=2
	PrimePi[4]=2
	PrimePi[5]=3
whereas 
	Prime[2]=3
	Prime[3]=5
	Prime[4]=7
	Prime[5]=11.

3.   Plot the ratio (p/(PrimePi[p])) between the p and the number of primes less than or equal to p, for all integers p between 2 and n.  Consider both small (<100) and large (>10,000) values of n.  Join the points on your plot with straight lines.  What do you observe?

primePlot[n_]:=ListPlot[Table[{p,(p/(PrimePi[p]))},{p,2,n}],Joined->True,PlotStyle->{Blue,Thickness[.008]}]

primeplotsmall=primePlot[50]

primeplotlarge=primePlot[20000]

4.  Plot the logarithm of p for all integers p between 2 and n.  Consider both small and large values of n.  Join the points on your plot with straight lines.

logprimePlot[n_]:=ListPlot[Table[{p,Log[p]},{p,2,n}],Joined->True,PlotStyle->{Darker[Green],Thickness[.008]}]

logplotsmall=logprimePlot[50]

logplotlarge=logprimePlot[20000]

5.  Plot the functions in parts 3 and 4 in the same graph. What do you observe?

Show[primeplotsmall,logplotsmall]
Show[primeplotlarge,logplotlarge]

6.  The built in Mathematica function LogIntegral computes the integral of (1/(Log[t])) between 0 and x.  Using the built in function LogIntegral, plot the ratio (p/((∫_0^p) 1/Log[t]  dt)) between p and the integral of (1/(Log[t])) from 0 to p, for all integers p between 2 and n.  Consider both small and large values of n.  Join the points on your plot with straight lines.  What do you observe?

logintegralPlot[n_]:=ListPlot[Table[{p,(p/(LogIntegral[p]))},{p,2,n}],Joined->True,PlotStyle->{Red,Thickness[.008]}]

logintegralplotsmall=logintegralPlot[50]

logintegralplotlarge=logintegralPlot[20000]

7.  Plot the functions in parts 3,4,6 in the same graph.  Consider both small and large values of n.  What do you observe?

Show[primeplotsmall,logplotsmall,logintegralplotsmall]

Show[primeplotlarge,logplotlarge,logintegralplotlarge]

Theorem :    (p/((∫_0^p) 1/Log[t]  dt)) < ((p )/(PrimePi[p])) <  Log[p]   for p > 20

diffPlot3[n_]:=ListPlot[{Table[{p,p/PrimePi[p]},{p,2,n}],Table[{p,p/LogIntegral[p]},{p,2,n}],Table[{p,Log[p]},{p,2,n}]},Axes->True,Joined->True,PlotStyle->Thickness[.008]]

diffPlot3[5000]

newdiffPlot3[m_,n_]:=ListPlot[{Table[{p,p/PrimePi[p]},{p,m,n}],Table[{p,p/LogIntegral[p]},{p,m,n}],Table[{p,Log[p]},{p,m,n}]},Axes->True,Joined->True,PlotStyle->Thickness[.008]]

newdiffPlot3[200,500]

newdiffPlot3[500,5000]

newdiffPlot3[5000,50000]