#..................................................................
#..................SAGE.CODE.USED.TO.BUILD.........................
#.......................THE.GRAPH.OF...............................
#..\[x\mapsto\frac{\lvert\pi(x)-Li(x)\rvert}{\sqrt{x}}\]...........
#..................................................................
#.....................PLEASE.FEEL.FREE.............................
#.....................TO.SEND.COMMENTS.............................
#..................................................................
#..............Sage.is.a.free.open-source..........................
#..............mathematics.software.system.........................
#................licensed.under.the.GPL............................
#...............http://www.sagemath.org/...........................
#..................................................................
Pmax=10^10
resolution_X=1920
#..........................................
Premiers=prime_range(Pmax)
#..........................................
pas=Pmax/(2*resolution_X)
abscisses=[2+RDF(k*pas) for k in range(2*resolution_X) if k != 0]
#..........................................
var('t')
Li=lambda x: numerical_integral(1/log(t),2,x)
#..........................................
Courbe=[(0,0)]
Compte=0
minY=0
maxY=0
for x in abscisses :
    remove=[]
    for p in Premiers :
       if p<=x :
	 remove.append(p)
	 Compte+=1
       else :
         break
    y=abs(Compte-Li(x)[0])/x.sqrt()
    if y>maxY: 
     maxY=y
    if y<minY:
     minY=y  
    Courbe.append([x,y])
    Premiers=[Premiers[i] for i in range(len(remove),len(Premiers))]	
#..........................................
g=line(Courbe,color='red')
#..........................................
Fichier_Courbe_Premiers='Courbe_Premiers_vs_Li_relatif'+str(Pmax)+'.pdf'
g.save(Fichier_Courbe_Premiers,ymin=minY,ymax=maxY)

